Contract.java
// license-header java merge-point
//
// Attention: Generated code! Do not modify by hand!
// Generated by hibernate/HibernateEntity.vsl in andromda-hibernate-cartridge on 08/18/2014 15:29:45-0400.
//
package org.andromda.samples.carrental.contracts;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import org.andromda.samples.carrental.customers.Customer;
import org.andromda.samples.carrental.customers.Driver;
import org.andromda.samples.carrental.inventory.Car;
/**
* <p>
* Contract between the car rental company and a customer.
* </p>
*/
// HibernateEntity.vsl annotations merge-point
public abstract class Contract
implements Serializable, Comparable<Contract>
{
/**
* The serial version UID of this class. Needed for serialization.
*/
private static final long serialVersionUID = 4673975888284135900L;
// Generate 3 attributes
private String contractNo;
/**
* <p>
* TODO: Model Documentation for contractNo
* </p>
* @return this.contractNo String
*/
public String getContractNo()
{
return this.contractNo;
}
/**
* <p>
* TODO: Model Documentation for contractNo
* </p>
* @param contractNoIn String
*/
public void setContractNo(String contractNoIn)
{
this.contractNo = contractNoIn;
}
private Date signed;
/**
* <p>
* TODO: Model Documentation for signed
* </p>
* @return this.signed Date
*/
public Date getSigned()
{
return this.signed;
}
/**
* <p>
* TODO: Model Documentation for signed
* </p>
* @param signedIn Date
*/
public void setSigned(Date signedIn)
{
this.signed = signedIn;
}
private Long id;
/**
* <p>
* TODO: Model Documentation for id
* </p>
* @return this.id Long
*/
public Long getId()
{
return this.id;
}
/**
* <p>
* TODO: Model Documentation for id
* </p>
* @param idIn Long
*/
public void setId(Long idIn)
{
this.id = idIn;
}
// Generate 6 associations
private HandoutDoc handoutDoc;
/**
* <p>
* TODO: Model Documentation for handoutDoc
* </p>
* @return this.handoutDoc HandoutDoc
*/
public HandoutDoc getHandoutDoc()
{
return this.handoutDoc;
}
/**
* <p>
* TODO: Model Documentation for handoutDoc
* </p>
* @param handoutDocIn HandoutDoc
*/
public void setHandoutDoc(HandoutDoc handoutDocIn)
{
this.handoutDoc = handoutDocIn;
}
private ReturnDoc returnDoc;
/**
* <p>
* TODO: Model Documentation for returnDoc
* </p>
* @return this.returnDoc ReturnDoc
*/
public ReturnDoc getReturnDoc()
{
return this.returnDoc;
}
/**
* <p>
* TODO: Model Documentation for returnDoc
* </p>
* @param returnDocIn ReturnDoc
*/
public void setReturnDoc(ReturnDoc returnDocIn)
{
this.returnDoc = returnDocIn;
}
private AccidentDoc accidentDoc;
/**
* <p>
* TODO: Model Documentation for accidentDoc
* </p>
* @return this.accidentDoc AccidentDoc
*/
public AccidentDoc getAccidentDoc()
{
return this.accidentDoc;
}
/**
* <p>
* TODO: Model Documentation for accidentDoc
* </p>
* @param accidentDocIn AccidentDoc
*/
public void setAccidentDoc(AccidentDoc accidentDocIn)
{
this.accidentDoc = accidentDocIn;
}
private Collection<Car> cars = new HashSet<Car>();
/**
* <p>
* TODO: Model Documentation for cars
* </p>
* @return this.cars Collection<Car>
*/
public Collection<Car> getCars()
{
return this.cars;
}
/**
* <p>
* TODO: Model Documentation for cars
* </p>
* @param carsIn Collection<Car>
*/
public void setCars(Collection<Car> carsIn)
{
this.cars = carsIn;
}
/**
* <p>
* TODO: Model Documentation for cars
* </p>
* @param elementToAdd Car
* @return <tt>true</tt> if this collection changed as a result of the
* call
*/
public boolean addCars(Car elementToAdd)
{
return this.cars.add(elementToAdd);
}
/**
* <p>
* TODO: Model Documentation for cars
* </p>
* @param elementToRemove Car
* @return <tt>true</tt> if this collection changed as a result of the
* call
*/
public boolean removeCars(Car elementToRemove)
{
return this.cars.remove(elementToRemove);
}
private Customer customer;
/**
* <p>
* TODO: Model Documentation for customer
* </p>
* @return this.customer Customer
*/
public Customer getCustomer()
{
return this.customer;
}
/**
* <p>
* TODO: Model Documentation for customer
* </p>
* @param customerIn Customer
*/
public void setCustomer(Customer customerIn)
{
this.customer = customerIn;
}
private Driver driver;
/**
* <p>
* TODO: Model Documentation for driver
* </p>
* @return this.driver Driver
*/
public Driver getDriver()
{
return this.driver;
}
/**
* <p>
* TODO: Model Documentation for driver
* </p>
* @param driverIn Driver
*/
public void setDriver(Driver driverIn)
{
this.driver = driverIn;
}
/**
* Returns <code>true</code> if the argument is an Contract instance and all identifiers for this entity
* equal the identifiers of the argument entity. Returns <code>false</code> otherwise.
*/
@Override
public boolean equals(Object object)
{
if (this == object)
{
return true;
}
if (!(object instanceof Contract))
{
return false;
}
final Contract that = (Contract)object;
if (this.id == null || that.getId() == null || !this.id.equals(that.getId()))
{
return false;
}
return true;
}
/**
* Returns a hash code based on this entity's identifiers.
*/
@Override
public int hashCode()
{
int hashCode = 0;
hashCode = 29 * hashCode + (this.id == null ? 0 : this.id.hashCode());
return hashCode;
}
/**
* Constructs new instances of {@link Contract}.
*/
public static final class Factory
{
/**
* Constructs a new instance of {@link Contract}.
* @return new ContractImpl()
*/
public static Contract newInstance()
{
return new ContractImpl();
}
/**
* Constructs a new instance of {@link Contract}, taking all required and/or
* read-only properties as arguments, except for identifiers.
* @param contractNo String
* @param signed Date
* @param handoutDoc HandoutDoc
* @param cars Collection<Car>
* @param customer Customer
* @return newInstance
*/
public static Contract newInstance(String contractNo, Date signed, HandoutDoc handoutDoc, Collection<Car> cars, Customer customer)
{
final Contract entity = new ContractImpl();
entity.setContractNo(contractNo);
entity.setSigned(signed);
entity.setHandoutDoc(handoutDoc);
entity.setCars(cars);
entity.setCustomer(customer);
return entity;
}
/**
* Constructs a new instance of {@link Contract}, taking all possible properties
* (except the identifier(s))as arguments.
* @param contractNo String
* @param signed Date
* @param handoutDoc HandoutDoc
* @param returnDoc ReturnDoc
* @param accidentDoc AccidentDoc
* @param cars Collection<Car>
* @param customer Customer
* @param driver Driver
* @return newInstance Contract
*/
public static Contract newInstance(String contractNo, Date signed, HandoutDoc handoutDoc, ReturnDoc returnDoc, AccidentDoc accidentDoc, Collection<Car> cars, Customer customer, Driver driver)
{
final Contract entity = new ContractImpl();
entity.setContractNo(contractNo);
entity.setSigned(signed);
entity.setHandoutDoc(handoutDoc);
entity.setReturnDoc(returnDoc);
entity.setAccidentDoc(accidentDoc);
entity.setCars(cars);
entity.setCustomer(customer);
entity.setDriver(driver);
return entity;
}
}
/**
* @param other
* @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
* @see Comparable#compareTo
*/
@Override
public int compareTo(Contract other)
{
int cmp = 0;
if (this.getId() != null)
{
cmp = this.getId().compareTo(other.getId());
}
else
{
if (this.getContractNo() != null)
{
cmp = (cmp != 0 ? cmp : this.getContractNo().compareTo(other.getContractNo()));
}
if (this.getSigned() != null)
{
cmp = (cmp != 0 ? cmp : this.getSigned().compareTo(other.getSigned()));
}
}
return cmp;
}
// HibernateEntity.vsl merge-point
}