📄 address.java
字号:
package com.cib.model;import java.io.Serializable;import javax.persistence.Column;import javax.persistence.Embeddable;import org.apache.commons.lang.builder.ToStringBuilder;import org.apache.commons.lang.builder.ToStringStyle;/** * 地址类,由省、市、地点和邮政编码构成. * * @author <a href="mailto:wunglee@163.com">wunglee</a> */@Embeddablepublic class Address extends BaseObject implements Serializable { private static final long serialVersionUID = 3617859655330969141L; private String address; private String city; private String province; private String country; private String postalCode; @Column(length=150) public String getAddress() { return address; } @Column(nullable=false,length=50) public String getCity() { return city; } @Column(length=100) public String getProvince() { return province; } @Column(length=100) public String getCountry() { return country; } @Column(name="postal_code",nullable=false,length=15) public String getPostalCode() { return postalCode; } public void setAddress(String address) { this.address = address; } public void setCity(String city) { this.city = city; } public void setCountry(String country) { this.country = country; } public void setPostalCode(String postalCode) { this.postalCode = postalCode; } public void setProvince(String province) { this.province = province; } /** * 复写父类的方法,基于hashcode进行比较. * @param o Object to compare * @return true/false based on hashCode */ public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Address)) { return false; } final Address address1 = (Address) o; return this.hashCode() == address1.hashCode(); } /** * 复写父类的方法,hashCode由省、市、地点和邮政编码的hashCode构成. * @return hashCode */ public int hashCode() { int result; result = (address != null ? address.hashCode() : 0); result = 29 * result + (city != null ? city.hashCode() : 0); result = 29 * result + (province != null ? province.hashCode() : 0); result = 29 * result + (country != null ? country.hashCode() : 0); result = 29 * result + (postalCode != null ? postalCode.hashCode() : 0); return result; } /** * 返回对象内部每个元素的信息. * @return a String representation of this class. */ public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) .append("country", this.country) .append("address", this.address) .append("province", this.province) .append("postalCode", this.postalCode) .append("city", this.city).toString(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -