CostLineTolerance.java
package com.tradecloud.domain.costing;
import com.tradecloud.common.base.PersistenceBase;
import com.tradecloud.domain.party.ServiceProvider;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.hibernate.annotations.ForeignKey;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* Entity that holds an upper and lower tolerance for a specific cost line.
*/
@Entity
@Table(name = "costlinetolerance")
@NamedQueries({@NamedQuery(name = "costLineTolerance.byCostGroupOrderedByCostLineName",
query = "select tolerance from CostLineTolerance as tolerance " + "join tolerance.costLineTemplate as template " + "where "
+ "template.costGroup = :costGroup order by tolerance.costLineTemplate.name")})
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "CostLineTolerance")
public class CostLineTolerance extends PersistenceBase implements Serializable, Comparable<CostLineTolerance> {
private static final long serialVersionUID = 1L;
@ManyToOne
@ForeignKey(name = "fk_costlinetemplate")
@JoinColumn(name = "costlinetemplate_code", unique = true)
@XmlElement(name = "CostLineTemplate")
@NotNull
private CostLineTemplate costLineTemplate;
@ManyToOne
@XmlElement(name = "serviceProvider")
private ServiceProvider serviceProvider;
@XmlAttribute
private BigDecimal lowerTolerance;
@XmlAttribute
private BigDecimal upperTolerance;
private boolean inUse;
public CostLineTemplate getCostLineTemplate() {
return costLineTemplate;
}
public void setCostLineTemplate(CostLineTemplate costLineTemplate) {
this.costLineTemplate = costLineTemplate;
}
@Override
public int compareTo(CostLineTolerance costLineTolerance) {
return costLineTemplate.getCode().compareTo(costLineTolerance.getCostLineTemplate().getCode());
}
public ServiceProvider getServiceProvider() {
return serviceProvider;
}
public void setServiceProvider(ServiceProvider serviceProvider) {
this.serviceProvider = serviceProvider;
}
@Override
public int hashCode() {
return new HashCodeBuilder().appendSuper(super.hashCode()).append(costLineTemplate).toHashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof CostLineTolerance)) {
return false;
}
CostLineTolerance other = (CostLineTolerance) obj;
return new EqualsBuilder().appendSuper(super.equals(other)).append(costLineTemplate, other.costLineTemplate).isEquals();
}
public BigDecimal getLowerTolerance() {
return lowerTolerance;
}
public void setLowerTolerance(BigDecimal lowerTolerance) {
this.lowerTolerance = lowerTolerance;
}
public BigDecimal getUpperTolerance() {
return upperTolerance;
}
public void setUpperTolerance(BigDecimal upperTolerance) {
this.upperTolerance = upperTolerance;
}
public boolean isInUse() {
return inUse;
}
public void setInUse(boolean inUse) {
this.inUse = inUse;
}
}