CarType.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;

/**
 * <p>
 * Represents a type of car. Several cars can belong to the same type.
 * </p>
 */
// HibernateEntity.vsl annotations merge-point
public abstract class CarType
    implements Serializable, Comparable<CarType>
{
    /**
     * The serial version UID of this class. Needed for serialization.
     */
    private static final long serialVersionUID = -8176715955705899850L;

    // Generate 5 attributes
    private String manufacturer;

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

    /**
     * <p>
     * TODO: Model Documentation for manufacturer
     * </p>
     * @param manufacturerIn String
     */
    public void setManufacturer(String manufacturerIn)
    {
        this.manufacturer = manufacturerIn;
    }

    private String identifier;

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

    /**
     * <p>
     * TODO: Model Documentation for identifier
     * </p>
     * @param identifierIn String
     */
    public void setIdentifier(String identifierIn)
    {
        this.identifier = identifierIn;
    }

    private String orderNo;

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

    /**
     * <p>
     * TODO: Model Documentation for orderNo
     * </p>
     * @param orderNoIn String
     */
    public void setOrderNo(String orderNoIn)
    {
        this.orderNo = orderNoIn;
    }

    private String comfortClass;

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

    /**
     * <p>
     * TODO: Model Documentation for comfortClass
     * </p>
     * @param comfortClassIn String
     */
    public void setComfortClass(String comfortClassIn)
    {
        this.comfortClass = comfortClassIn;
    }

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

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

        /**
         * Constructs a new instance of {@link CarType}, taking all required and/or
         * read-only properties as arguments, except for identifiers.
         * @param manufacturer String
         * @param identifier String
         * @param orderNo String
         * @param comfortClass String
         * @return newInstance
         */
        public static CarType newInstance(String manufacturer, String identifier, String orderNo, String comfortClass)
        {
            final CarType entity = new CarTypeImpl();
            entity.setManufacturer(manufacturer);
            entity.setIdentifier(identifier);
            entity.setOrderNo(orderNo);
            entity.setComfortClass(comfortClass);
            return entity;
        }

        /**
         * Constructs a new instance of {@link CarType}, taking all possible properties
         * (except the identifier(s))as arguments.
         * @param manufacturer String
         * @param identifier String
         * @param orderNo String
         * @param comfortClass String
         * @param cars Collection<Car>
         * @return newInstance CarType
         */
        public static CarType newInstance(String manufacturer, String identifier, String orderNo, String comfortClass, Collection<Car> cars)
        {
            final CarType entity = new CarTypeImpl();
            entity.setManufacturer(manufacturer);
            entity.setIdentifier(identifier);
            entity.setOrderNo(orderNo);
            entity.setComfortClass(comfortClass);
            entity.setCars(cars);
            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(CarType other)
    {
        int cmp = 0;
        if (this.getId() != null)
        {
            cmp = this.getId().compareTo(other.getId());
        }
        else
        {
            if (this.getManufacturer() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getManufacturer().compareTo(other.getManufacturer()));
            }
            if (this.getIdentifier() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getIdentifier().compareTo(other.getIdentifier()));
            }
            if (this.getOrderNo() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getOrderNo().compareTo(other.getOrderNo()));
            }
            if (this.getComfortClass() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getComfortClass().compareTo(other.getComfortClass()));
            }
        }
        return cmp;
    }
// HibernateEntity.vsl merge-point
}