下面Java代码如何用Golang来写?

public class Todo {
    private String name;
    private Date until;
    private String details;

    public Todo(String name, String detail, Date until) {
        this.name = name;
        this.details = detail;
        this.until = until;
    }

    public Todo() {
        this.name = "";
        this.details = "";
        this.until = new Date();
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getUntil() {
        return this.until;
    }

    public void setUntil(Date until) {
        this.until = until;
    }

    public String getDetails() {
        return this.details;
    }

    public void setDetails(String details) {
        this.details = details;
    }

    public int hashCode() {
        int prime = true;
        int result = 1;
        int result = 31 * result + (this.details == null ? 0 : this.details.hashCode());
        result = 31 * result + (this.name == null ? 0 : this.name.hashCode());
        result = 31 * result + (this.until == null ? 0 : this.until.hashCode());
        return result;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        } else if (obj == null) {
            return false;
        } else if (this.getClass() != obj.getClass()) {
            return false;
        } else {
            Todo other = (Todo)obj;
            if (this.details == null) {
                if (other.details != null) {
                    return false;
                }
            } else if (!this.details.equals(other.details)) {
                return false;
            }

            if (this.name == null) {
                if (other.name != null) {
                    return false;
                }
            } else if (!this.name.equals(other.name)) {
                return false;
            }

            if (this.until == null) {
                if (other.until != null) {
                    return false;
                }
            } else if (!this.until.equals(other.until)) {
                return false;
            }

            return true;
        }
    }
}


时务者
浏览 1371回答 0
0回答
打开App,查看更多内容
随时随地看视频慕课网APP