PaperTicket.java

// license-header java merge-point
//
// Attention: Generated code! Do not modify by hand!
// Generated by EntityEmbeddable.vsl in andromda-ejb3-cartridge on 08/08/2014 12:21:03.
//
package org.andromda.demo.ejb3.ticket;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * TODO: Model Documentation for org.andromda.demo.ejb3.ticket.PaperTicket
 * </p>
 *
 * Autogenerated POJO EJB class for PaperTicket containing the
 * bulk of the entity implementation.
 *
 * This is autogenerated by AndroMDA using the EJB3
 * cartridge.
 *
 * DO NOT MODIFY this class.
 */
@Entity
@Table(name="PAPER_TICKET")
@NamedQuery(name="PaperTicket.findAll", query="SELECT p FROM PaperTicket AS p")
public class PaperTicket
    extends Ticket
    implements Serializable, Comparable<PaperTicket>{
    private static final long serialVersionUID = 3023908434531519531L;

    // ----------- 2 Attribute Definitions ------------
    protected Date posted;
    protected long handlingFee;

    // -------- 2 Attribute Accessors ----------
    /**
     * <p>
     * TODO: Model Documentation for posted
     * </p>
     * Get the posted property.
     * @return Date The value of posted
     */
    @Column(name="POSTED", nullable=false, insertable=true, updatable=true)
    @Temporal(TemporalType.TIMESTAMP)
    @NotNull(message="posted is required")
    public Date getPosted()
    {
        return this.posted;
    }

    /**
     * <p>
     * TODO: Model Documentation for posted
     * </p>
     * Set the posted property.
     * @param value the new value
     */
    public void setPosted(Date value)
    {
        this.posted = value;
    }

    /**
     * <p>
     * TODO: Model Documentation for handlingFee
     * </p>
     * Get the handlingFee property.
     * @return long The value of handlingFee
     */
    @Column(name="HANDLING_FEE", nullable=false, insertable=true, updatable=true)
    @NotNull(message="handlingFee is required")
    public long getHandlingFee()
    {
        return this.handlingFee;
    }

    /**
     * <p>
     * TODO: Model Documentation for handlingFee
     * </p>
     * Set the handlingFee property.
     * @param value the new value
     */
    public void setHandlingFee(long value)
    {
        this.handlingFee = value;
    }


    // ------------- 0 Relations ------------------
    // --------------- Constructors -----------------

    /**
     * Default empty no-arg constructor
     */
    public PaperTicket()
    {
        // Default empty constructor
    }

    /**
     * Constructor with all updatable Entity attributes except auto incremented identifiers.
     *
     * @param event String value for the event property required=true lower=1
     * @param type String value for the type property required=false lower=0
     * @param posted Date value for the posted property required=true lower=1
     * @param handlingFee long value for the handlingFee property required=true lower=1
     */
    public PaperTicket(String event, String type, Date posted, long handlingFee)
    {
        this.event = event;
        this.type = type;
        this.posted = posted;
        this.handlingFee = handlingFee;
    }

    /**
     * Constructor with required Entity attributes except auto incremented identifiers.
     *
     * @param event Value for the event property
     * @param posted Value for the posted property
     * @param handlingFee Value for the handlingFee property
     */
    public PaperTicket(String event, Date posted, long handlingFee)
    {
        this.event = event;
        this.posted = posted;
        this.handlingFee = handlingFee;
    }


    // -------- Common Methods -----------
    /**
     * Indicates if the argument is of the same type and all values are equal.
     * @param object The target object to compare with
     * @return boolean True if both objects a 'equal'
     * @see Object#equals(Object)
     */
    @Override
    public boolean equals(Object object)
    {
        if (null == object)
        {
            return false;
        }
        if (this == object)
        {
            return true;
        }
        if (!(object instanceof PaperTicket))
        {
            return false;
        }
        final PaperTicket that = (PaperTicket)object;
        if (this.getId() == null || that.getId() == null || !this.getId().equals(that.getId()))
        {
            return false;
        }
        return true;
    }

    /**
     * Returns a hash code value for the object
     * @return int The hash code value
     * @see Object#hashCode
     */
    @Override
    public int hashCode()
    {
        int hashCode = super.hashCode();
        hashCode = 29 * hashCode + (getId() == null ? 0 : getId().hashCode());

        return hashCode;
    }

    /**
     * Returns a String representation of the object
     * @return String Textual representation of the object displaying name/value pairs for all attributes
     * @see Object#toString
     */
    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append("PaperTicket(");
        sb.append(super.toString());
        sb.append(" posted=").append(getPosted());
        sb.append(" handlingFee=").append(getHandlingFee());
        sb.append(" id=").append(getId());
        sb.append(" event=").append(getEvent());
        sb.append(" type=").append(getType());
        sb.append(")");
        return sb.toString();
    }

    /**
     * @see Comparable#compareTo
     */
    @Override
    public int compareTo(PaperTicket o)
    {
        int cmp = 0;
        if (this.getId() != null)
        {
            cmp = this.getId().compareTo(o.getId());
        }
        else
        {
            if (this.getPosted() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getPosted().compareTo(o.getPosted()));
            }
            if (this.getEvent() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getEvent().compareTo(o.getEvent()));
            }
            if (this.getType() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getType().compareTo(o.getType()));
            }
        }
        return cmp;
    }


}