/*
* Copyright 2011 Thingtrack, S.L.
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.thingtrack.konekti.domain;
/*
* #%L
* Konekti Domain Layer
* $Id:$
* $HeadURL:$
* %%
* Copyright (C) 2010 - 2014 Thingtrack s.l.
* %%
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* entity class
* <p>
* Represents types of product
* @author Thingtrack S.L.
*
*/
@SuppressWarnings("serial")
@XmlRootElement
@Entity
@Table(name="PRODUCT_TYPE", uniqueConstraints=@UniqueConstraint(columnNames={"CODE", "AREA_ID"}))
public class ProductType implements Serializable {
/**
* Unique identifier
*/
@Id
@Column(name="PRODUCT_TYPE_ID")
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer productTypeId;
/**
* Unique code, not null
*/
@Column(name="CODE", nullable=false, length=64)
private String code;
/**
* Description
*/
@Column(name="DESCRIPTION", length=512)
private String description;
@ManyToOne
@JoinColumn(name="AREA_ID", nullable=false)
private Area area;
/**
* @param productTypeId the productTypeId to set
*/
@XmlAttribute
public void setProductTypeId(Integer productTypeId) {
this.productTypeId = productTypeId;
}
/**
* @return the productTypeId
*/
public Integer getProductTypeId() {
return productTypeId;
}
/**
* @param code the code to set
*/
@XmlElement
public void setCode(String code) {
this.code = code;
}
/**
* @return the code
*/
public String getCode() {
return code;
}
/**
* @param description the description to set
*/
@XmlElement
public void setDescription(String description) {
this.description = description;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((code == null) ? 0 : code.hashCode());
result = prime * result
+ ((productTypeId == null) ? 0 : productTypeId.hashCode());
return result;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof ProductType))
return false;
ProductType other = (ProductType) obj;
if (code == null) {
if (other.code != null)
return false;
} else if (!code.equals(other.code))
return false;
if (productTypeId == null) {
if (other.productTypeId != null)
return false;
} else if (!productTypeId.equals(other.productTypeId))
return false;
return true;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "ProductType [productTypeId=" + productTypeId + ", code=" + code
+ ", description=" + description + "]";
}
public Area getArea() {
return area;
}
public void setArea(Area area) {
this.area = area;
}
}