RentalCar.java

// license-header java merge-point
//
// This file can be safely modified. If deleted it will be regenerated.
// Generated by Entity.vsl in andromda-ejb3-cartridge on 08/06/2014 10:56:20.
//
package org.andromda.demo.ejb3.rental;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * Autogenerated POJO EJB3 implementation class for RentalCar.
 *
 * Add any manual implementation within this class.  This class will NOT
 * be overwritten with incremental changes.
 *
 * <p>
 * TODO: Model Documentation for org.andromda.demo.ejb3.rental.RentalCar
 * </p>
 *
 */

@Entity
@Table(name = "RENTAL_CAR")
// Uncomment to enable entity listener for RentalCar
// @javax.persistence.EntityListeners({org.andromda.demo.ejb3.rental.RentalCarListener.class})
// Uncomment to enable caching for RentalCar
// @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.TRANSACTIONAL)
@NamedQuery(name = "RentalCar.findAll", query = "SELECT r FROM RentalCar AS r")
public class RentalCar
    extends RentalCarEmbeddable
    implements Serializable, Comparable<RentalCar>
{
    /**
     * The serial version UID of this class required for serialization.
     */
    private static final long serialVersionUID = -1685771601926983114L;

    // --------------- constructors -----------------

    /**
     * Default RentalCar constructor
     */
    public RentalCar()
    {
        super();
    }

    /**
     * Implementation for the constructor with all POJO attributes except auto incremented identifiers.
     * This method sets all POJO fields defined in this/super class to the
     * values provided by the parameters.
     *
     */
    public RentalCar(String serial, String name, CarType type)
    {
        super(serial, name, type);
    }

    /**
     * Constructor with all POJO attribute values and CMR relations.
     *
     * @param serial Value for the serial property
     * @param name Value for the name property
     * @param type Value for the type property
     * @param owner Value for the owner relation role
     */
    public RentalCar(String serial, String name, CarType type, Person owner)
    {
        super(serial, name, type, owner);
    }

    // -------------- Entity Methods -----------------

    /**
     * <p>
     * TODO: Model Documentation for isRented
     * </p>
     */
    @Transient
    public boolean isRented()
    {
        // TODO put your implementation here.
        return false;
    }

    /**
     * <p>
     * TODO: Model Documentation for allCarsAreRented
     * </p>
     */
    @Transient
    public static boolean allCarsAreRented()
    {
        // TODO put your implementation here.
        return false;
    }

    // --------------- Lifecycle callbacks -----------------

    /**
     * @see Comparable#compareTo
     */
    @Override
    public int compareTo(RentalCar o)
    {
        int cmp = 0;
        if (this.getRentalCarId() != null)
        {
            cmp = this.getRentalCarId().compareTo(o.getRentalCarId());
        }
        else
        {
            if (this.getSerial() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getSerial().compareTo(o.getSerial()));
            }
            if (this.getName() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getName().compareTo(o.getName()));
            }
            if (this.getType() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getType().compareTo(o.getType()));
            }
        }
        return cmp;
    }
}