Driver.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.Date;
import java.util.HashSet;
import org.andromda.samples.carrental.contracts.Contract;

/**
 * <p>
 * Represents a driver who is an employee of the customer's company.
 * </p>
 */
// HibernateEntity.vsl annotations merge-point
public abstract class Driver
    implements Serializable, Comparable<Driver>
{
    /**
     * The serial version UID of this class. Needed for serialization.
     */
    private static final long serialVersionUID = -5242901245721506161L;

    // Generate 6 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 surname;

    /**
     * <p>
     * TODO: Model Documentation for surname
     * </p>
     * @return this.surname String
     */
    public String getSurname()
    {
        return this.surname;
    }

    /**
     * <p>
     * TODO: Model Documentation for surname
     * </p>
     * @param surnameIn String
     */
    public void setSurname(String surnameIn)
    {
        this.surname = surnameIn;
    }

    private Date birthDate;

    /**
     * <p>
     * TODO: Model Documentation for birthDate
     * </p>
     * @return this.birthDate Date
     */
    public Date getBirthDate()
    {
        return this.birthDate;
    }

    /**
     * <p>
     * TODO: Model Documentation for birthDate
     * </p>
     * @param birthDateIn Date
     */
    public void setBirthDate(Date birthDateIn)
    {
        this.birthDate = birthDateIn;
    }

    private String licenseNo;

    /**
     * <p>
     * TODO: Model Documentation for licenseNo
     * </p>
     * @return this.licenseNo String
     */
    public String getLicenseNo()
    {
        return this.licenseNo;
    }

    /**
     * <p>
     * TODO: Model Documentation for licenseNo
     * </p>
     * @param licenseNoIn String
     */
    public void setLicenseNo(String licenseNoIn)
    {
        this.licenseNo = licenseNoIn;
    }

    private String licenseIssuedBy;

    /**
     * <p>
     * TODO: Model Documentation for licenseIssuedBy
     * </p>
     * @return this.licenseIssuedBy String
     */
    public String getLicenseIssuedBy()
    {
        return this.licenseIssuedBy;
    }

    /**
     * <p>
     * TODO: Model Documentation for licenseIssuedBy
     * </p>
     * @param licenseIssuedByIn String
     */
    public void setLicenseIssuedBy(String licenseIssuedByIn)
    {
        this.licenseIssuedBy = licenseIssuedByIn;
    }

    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 2 associations
    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 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);
    }

    /**
     * Returns <code>true</code> if the argument is an Driver 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 Driver))
        {
            return false;
        }
        final Driver that = (Driver)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 Driver}.
     */
    public static final class Factory
    {
        /**
         * Constructs a new instance of {@link Driver}.
         * @return new DriverImpl()
         */
        public static Driver newInstance()
        {
            return new DriverImpl();
        }

        /**
         * Constructs a new instance of {@link Driver}, taking all required and/or
         * read-only properties as arguments, except for identifiers.
         * @param name String
         * @param birthDate Date
         * @param licenseNo String
         * @param licenseIssuedBy String
         * @param customer Customer
         * @return newInstance
         */
        public static Driver newInstance(String name, Date birthDate, String licenseNo, String licenseIssuedBy, Customer customer)
        {
            final Driver entity = new DriverImpl();
            entity.setName(name);
            entity.setBirthDate(birthDate);
            entity.setLicenseNo(licenseNo);
            entity.setLicenseIssuedBy(licenseIssuedBy);
            entity.setCustomer(customer);
            return entity;
        }

        /**
         * Constructs a new instance of {@link Driver}, taking all possible properties
         * (except the identifier(s))as arguments.
         * @param name String
         * @param surname String
         * @param birthDate Date
         * @param licenseNo String
         * @param licenseIssuedBy String
         * @param customer Customer
         * @param contracts Collection<Contract>
         * @return newInstance Driver
         */
        public static Driver newInstance(String name, String surname, Date birthDate, String licenseNo, String licenseIssuedBy, Customer customer, Collection<Contract> contracts)
        {
            final Driver entity = new DriverImpl();
            entity.setName(name);
            entity.setSurname(surname);
            entity.setBirthDate(birthDate);
            entity.setLicenseNo(licenseNo);
            entity.setLicenseIssuedBy(licenseIssuedBy);
            entity.setCustomer(customer);
            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(Driver 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.getSurname() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getSurname().compareTo(other.getSurname()));
            }
            if (this.getBirthDate() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getBirthDate().compareTo(other.getBirthDate()));
            }
            if (this.getLicenseNo() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getLicenseNo().compareTo(other.getLicenseNo()));
            }
            if (this.getLicenseIssuedBy() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getLicenseIssuedBy().compareTo(other.getLicenseIssuedBy()));
            }
        }
        return cmp;
    }
// HibernateEntity.vsl merge-point
}