Car.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.inventory;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
import org.andromda.samples.carrental.contracts.Contract;
/**
* <p>
* Represents a car.
* </p>
*/
// HibernateEntity.vsl annotations merge-point
public abstract class Car
implements Serializable, Comparable<Car>
{
/**
* The serial version UID of this class. Needed for serialization.
*/
private static final long serialVersionUID = 7206923235036297639L;
// Generate 3 attributes
private String registrationNo;
/**
* <p>
* TODO: Model Documentation for registrationNo
* </p>
* @return this.registrationNo String
*/
public String getRegistrationNo()
{
return this.registrationNo;
}
/**
* <p>
* TODO: Model Documentation for registrationNo
* </p>
* @param registrationNoIn String
*/
public void setRegistrationNo(String registrationNoIn)
{
this.registrationNo = registrationNoIn;
}
private String inventoryNo;
/**
* <p>
* TODO: Model Documentation for inventoryNo
* </p>
* @return this.inventoryNo String
*/
public String getInventoryNo()
{
return this.inventoryNo;
}
/**
* <p>
* TODO: Model Documentation for inventoryNo
* </p>
* @param inventoryNoIn String
*/
public void setInventoryNo(String inventoryNoIn)
{
this.inventoryNo = inventoryNoIn;
}
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 3 associations
private Collection<Contract> contracts = new HashSet<Contract>();
/**
* <p>
* TODO: Model Documentation for contracts
* </p>
* @return this.contracts Collection<Contract>
*/
public Collection<Contract> getContracts()
{
return this.contracts;
}
/**
* <p>
* TODO: Model Documentation for contracts
* </p>
* @param contractsIn Collection<Contract>
*/
public void setContracts(Collection<Contract> contractsIn)
{
this.contracts = contractsIn;
}
/**
* <p>
* TODO: Model Documentation for contracts
* </p>
* @param elementToAdd Contract
* @return <tt>true</tt> if this collection changed as a result of the
* call
*/
public boolean addContracts(Contract elementToAdd)
{
return this.contracts.add(elementToAdd);
}
/**
* <p>
* TODO: Model Documentation for contracts
* </p>
* @param elementToRemove Contract
* @return <tt>true</tt> if this collection changed as a result of the
* call
*/
public boolean removeContracts(Contract elementToRemove)
{
return this.contracts.remove(elementToRemove);
}
private Collection<CarAccessory> carAccessories = new HashSet<CarAccessory>();
/**
* <p>
* TODO: Model Documentation for carAccessories
* </p>
* @return this.carAccessories Collection<CarAccessory>
*/
public Collection<CarAccessory> getCarAccessories()
{
return this.carAccessories;
}
/**
* <p>
* TODO: Model Documentation for carAccessories
* </p>
* @param carAccessoriesIn Collection<CarAccessory>
*/
public void setCarAccessories(Collection<CarAccessory> carAccessoriesIn)
{
this.carAccessories = carAccessoriesIn;
}
/**
* <p>
* TODO: Model Documentation for carAccessories
* </p>
* @param elementToAdd CarAccessory
* @return <tt>true</tt> if this collection changed as a result of the
* call
*/
public boolean addCarAccessories(CarAccessory elementToAdd)
{
return this.carAccessories.add(elementToAdd);
}
/**
* <p>
* TODO: Model Documentation for carAccessories
* </p>
* @param elementToRemove CarAccessory
* @return <tt>true</tt> if this collection changed as a result of the
* call
*/
public boolean removeCarAccessories(CarAccessory elementToRemove)
{
return this.carAccessories.remove(elementToRemove);
}
private CarType carType;
/**
* <p>
* TODO: Model Documentation for carType
* </p>
* @return this.carType CarType
*/
public CarType getCarType()
{
return this.carType;
}
/**
* <p>
* TODO: Model Documentation for carType
* </p>
* @param carTypeIn CarType
*/
public void setCarType(CarType carTypeIn)
{
this.carType = carTypeIn;
}
// Generate 1 businessOperations
/**
* <p>
* TODO: Model Documentation for create
* </p>
* @param id <p>
TODO: Model Documentation for id
</p>
* @param registrationNumber <p>
TODO: Model Documentation for registrationNumber
</p>
* @param inventoryNumber <p>
TODO: Model Documentation for inventoryNumber
</p>
* @return Car
*/
public abstract Car create(Long id, String registrationNumber, String inventoryNumber);
/**
* Returns <code>true</code> if the argument is an Car 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 Car))
{
return false;
}
final Car that = (Car)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 Car}.
*/
public static final class Factory
{
/**
* Constructs a new instance of {@link Car}.
* @return new CarImpl()
*/
public static Car newInstance()
{
return new CarImpl();
}
/**
* Constructs a new instance of {@link Car}, taking all required and/or
* read-only properties as arguments, except for identifiers.
* @param registrationNo String
* @param inventoryNo String
* @param carType CarType
* @return newInstance
*/
public static Car newInstance(String registrationNo, String inventoryNo, CarType carType)
{
final Car entity = new CarImpl();
entity.setRegistrationNo(registrationNo);
entity.setInventoryNo(inventoryNo);
entity.setCarType(carType);
return entity;
}
/**
* Constructs a new instance of {@link Car}, taking all possible properties
* (except the identifier(s))as arguments.
* @param registrationNo String
* @param inventoryNo String
* @param contracts Collection<Contract>
* @param carAccessories Collection<CarAccessory>
* @param carType CarType
* @return newInstance Car
*/
public static Car newInstance(String registrationNo, String inventoryNo, Collection<Contract> contracts, Collection<CarAccessory> carAccessories, CarType carType)
{
final Car entity = new CarImpl();
entity.setRegistrationNo(registrationNo);
entity.setInventoryNo(inventoryNo);
entity.setContracts(contracts);
entity.setCarAccessories(carAccessories);
entity.setCarType(carType);
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(Car other)
{
int cmp = 0;
if (this.getId() != null)
{
cmp = this.getId().compareTo(other.getId());
}
else
{
if (this.getRegistrationNo() != null)
{
cmp = (cmp != 0 ? cmp : this.getRegistrationNo().compareTo(other.getRegistrationNo()));
}
if (this.getInventoryNo() != null)
{
cmp = (cmp != 0 ? cmp : this.getInventoryNo().compareTo(other.getInventoryNo()));
}
}
return cmp;
}
// HibernateEntity.vsl merge-point
}