📄 addressvo.java
字号:
/*******************************************************************************
* ***** BEGIN LICENSE BLOCK Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The Original Code is the OpenCustomer CRM.
*
* The Initial Developer of the Original Code is Thomas Bader (Bader & Jene
* Software-Ingenieurb黵o). Portions created by the Initial Developer are
* Copyright (C) 2005 the Initial Developer. All Rights Reserved.
*
* Contributor(s): Thomas Bader <thomas.bader@bader-jene.de>
*
* ***** END LICENSE BLOCK *****
*/
package org.opencustomer.application.db.vo.crm;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.opencustomer.db.vo.UndeletableVO;
@Entity
@Table(name = "address")
@AttributeOverride(name = "id", column = @Column(name = "address_id"))
public class AddressVO extends UndeletableVO
{
private static final long serialVersionUID = 3906645319163656497L;
public static enum Type {
COMPANY,
POSTAL,
BILLING,
DELIVERY;
}
private Type type;
private String name1;
private String name2;
private String name3;
private String street;
private String postbox;
private String zip;
private String city;
private PersonVO person;
private CompanyVO company;
public AddressVO()
{
}
public AddressVO(CompanyVO company, Type type)
{
setCompany(company);
setType(type);
}
@Column(name = "city")
public String getCity()
{
return city;
}
public void setCity(String city)
{
this.city = city;
}
@ManyToOne
@JoinColumn(name = "company_id")
public CompanyVO getCompany()
{
return company;
}
public void setCompany(CompanyVO company)
{
this.company = company;
}
@Column(name = "name_1")
public String getName1()
{
return name1;
}
public void setName1(String name1)
{
this.name1 = name1;
}
@Column(name = "name_2")
public String getName2()
{
return name2;
}
public void setName2(String name2)
{
this.name2 = name2;
}
@Column(name = "name_3")
public String getName3()
{
return name3;
}
public void setName3(String name3)
{
this.name3 = name3;
}
@ManyToOne
@JoinColumn(name = "person_id")
public PersonVO getPerson()
{
return person;
}
public void setPerson(PersonVO person)
{
this.person = person;
}
@Column(name = "postbox")
public String getPostbox()
{
return postbox;
}
public void setPostbox(String postbox)
{
this.postbox = postbox;
}
@Column(name = "street")
public String getStreet()
{
return street;
}
public void setStreet(String street)
{
this.street = street;
}
@Column(name = "address_type")
@Enumerated(EnumType.STRING)
public Type getType()
{
return type;
}
public void setType(Type type)
{
this.type = type;
}
@Column(name = "zip")
public String getZip()
{
return zip;
}
public void setZip(String zip)
{
this.zip = zip;
}
protected void toString(ToStringBuilder builder)
{
builder.append("type=" + type);
builder.append("name1=" + name1);
builder.append("name2=" + name2);
builder.append("name3=" + name3);
builder.append("street=" + street);
builder.append("postbox=" + postbox);
builder.append("zip=" + zip);
builder.append("city=" + city);
}
@Override
public boolean equals(Object obj)
{
boolean isEqual = false;
if (obj == null)
isEqual = false;
else if (this == obj)
isEqual = true;
else if (!(obj instanceof AddressVO))
isEqual = false;
else
{
AddressVO castObj = (AddressVO) obj;
EqualsBuilder builder = new EqualsBuilder();
builder.append(this.getCompany(), castObj.getCompany());
builder.append(this.getType(), castObj.getType());
isEqual = builder.isEquals();
}
return isEqual;
}
@Override
public int hashCode()
{
HashCodeBuilder builder = new HashCodeBuilder();
builder.append(getCompany());
builder.append(getType());
return builder.toHashCode();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -