Customer.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.customers;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
import org.andromda.samples.carrental.contracts.Contract;
import org.andromda.samples.carrental.contracts.Reservation;
/**
* <p>
* Represents a customer in the car rental system.
* </p>
*/
// HibernateEntity.vsl annotations merge-point
public abstract class Customer
implements Serializable, Comparable<Customer>
{
/**
* The serial version UID of this class. Needed for serialization.
*/
private static final long serialVersionUID = 2379174513186721366L;
// Generate 4 attributes
private String name;
/**
* <p>
* TODO: Model Documentation for name
* </p>
* @return this.name String
*/
public String getName()
{
return this.name;
}
/**
* <p>
* TODO: Model Documentation for name
* </p>
* @param nameIn String
*/
public void setName(String nameIn)
{
this.name = nameIn;
}
private String customerNo;
/**
* <p>
* TODO: Model Documentation for customerNo
* </p>
* @return this.customerNo String
*/
public String getCustomerNo()
{
return this.customerNo;
}
/**
* <p>
* TODO: Model Documentation for customerNo
* </p>
* @param customerNoIn String
*/
public void setCustomerNo(String customerNoIn)
{
this.customerNo = customerNoIn;
}
private String password;
/**
* <p>
* TODO: Model Documentation for password
* </p>
* @return this.password String
*/
public String getPassword()
{
return this.password;
}
/**
* <p>
* TODO: Model Documentation for password
* </p>
* @param passwordIn String
*/
public void setPassword(String passwordIn)
{
this.password = passwordIn;
}
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<Reservation> reservations = new HashSet<Reservation>();
/**
* <p>
* TODO: Model Documentation for reservations
* </p>
* @return this.reservations Collection<Reservation>
*/
public Collection<Reservation> getReservations()
{
return this.reservations;
}
/**
* <p>
* TODO: Model Documentation for reservations
* </p>
* @param reservationsIn Collection<Reservation>
*/
public void setReservations(Collection<Reservation> reservationsIn)
{
this.reservations = reservationsIn;
}
/**
* <p>
* TODO: Model Documentation for reservations
* </p>
* @param elementToAdd Reservation
* @return <tt>true</tt> if this collection changed as a result of the
* call
*/
public boolean addReservations(Reservation elementToAdd)
{
return this.reservations.add(elementToAdd);
}
/**
* <p>
* TODO: Model Documentation for reservations
* </p>
* @param elementToRemove Reservation
* @return <tt>true</tt> if this collection changed as a result of the
* call
*/
public boolean removeReservations(Reservation elementToRemove)
{
return this.reservations.remove(elementToRemove);
}
private Collection<Driver> drivers = new HashSet<Driver>();
/**
* <p>
* TODO: Model Documentation for drivers
* </p>
* @return this.drivers Collection<Driver>
*/
public Collection<Driver> getDrivers()
{
return this.drivers;
}
/**
* <p>
* TODO: Model Documentation for drivers
* </p>
* @param driversIn Collection<Driver>
*/
public void setDrivers(Collection<Driver> driversIn)
{
this.drivers = driversIn;
}
/**
* <p>
* TODO: Model Documentation for drivers
* </p>
* @param elementToAdd Driver
* @return <tt>true</tt> if this collection changed as a result of the
* call
*/
public boolean addDrivers(Driver elementToAdd)
{
return this.drivers.add(elementToAdd);
}
/**
* <p>
* TODO: Model Documentation for drivers
* </p>
* @param elementToRemove Driver
* @return <tt>true</tt> if this collection changed as a result of the
* call
*/
public boolean removeDrivers(Driver elementToRemove)
{
return this.drivers.remove(elementToRemove);
}
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);
}
// Generate 2 businessOperations
/**
* <p>
* TODO: Model Documentation for addDriver
* </p>
* @param driver <p>
TODO: Model Documentation for driver
</p>
* @throws CustomerException
*/
public abstract void addDriver(Driver driver)
throws CustomerException;
/**
* <p>
* TODO: Model Documentation for create
* </p>
* @param id <p>
TODO: Model Documentation for id
</p>
* @param name <p>
TODO: Model Documentation for name
</p>
* @param customerNo <p>
TODO: Model Documentation for customerNo
</p>
* @param password <p>
TODO: Model Documentation for password
</p>
* @return Customer
* @throws CustomerException
*/
public abstract Customer create(long id, String name, String customerNo, String password)
throws CustomerException;
/**
* Returns <code>true</code> if the argument is an Customer 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 Customer))
{
return false;
}
final Customer that = (Customer)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 Customer}.
*/
public static final class Factory
{
/**
* Constructs a new instance of {@link Customer}.
* @return new CustomerImpl()
*/
public static Customer newInstance()
{
return new CustomerImpl();
}
/**
* Constructs a new instance of {@link Customer}, taking all required and/or
* read-only properties as arguments, except for identifiers.
* @param name String
* @param customerNo String
* @param password String
* @return newInstance
*/
public static Customer newInstance(String name, String customerNo, String password)
{
final Customer entity = new CustomerImpl();
entity.setName(name);
entity.setCustomerNo(customerNo);
entity.setPassword(password);
return entity;
}
/**
* Constructs a new instance of {@link Customer}, taking all possible properties
* (except the identifier(s))as arguments.
* @param name String
* @param customerNo String
* @param password String
* @param reservations Collection<Reservation>
* @param drivers Collection<Driver>
* @param contracts Collection<Contract>
* @return newInstance Customer
*/
public static Customer newInstance(String name, String customerNo, String password, Collection<Reservation> reservations, Collection<Driver> drivers, Collection<Contract> contracts)
{
final Customer entity = new CustomerImpl();
entity.setName(name);
entity.setCustomerNo(customerNo);
entity.setPassword(password);
entity.setReservations(reservations);
entity.setDrivers(drivers);
entity.setContracts(contracts);
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(Customer other)
{
int cmp = 0;
if (this.getId() != null)
{
cmp = this.getId().compareTo(other.getId());
}
else
{
if (this.getName() != null)
{
cmp = (cmp != 0 ? cmp : this.getName().compareTo(other.getName()));
}
if (this.getCustomerNo() != null)
{
cmp = (cmp != 0 ? cmp : this.getCustomerNo().compareTo(other.getCustomerNo()));
}
if (this.getPassword() != null)
{
cmp = (cmp != 0 ? cmp : this.getPassword().compareTo(other.getPassword()));
}
}
return cmp;
}
// HibernateEntity.vsl merge-point
}