GrantInfo.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:04.
//
package org.andromda.demo.ejb3.athlete;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

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

    // ----------- 3 Attribute Definitions ------------
    protected String code;
    protected String name;
    protected Long grantInfoId;

    // --------- 1 Relationship Definitions -----------
    protected Sponsor sponsor;

    // ---- Manageable Display Attributes (Transient) -----

    // -------- 3 Attribute Accessors ----------
    /**
     * <p>
     * TODO: Model Documentation for code
     * </p>
     * Get the code property.
     * @return String The value of code
     */
    @Column(name="CODE", nullable=false, insertable=true, updatable=true, length=20)
    @NotNull(message="code is required")
    @Size(max=20)
    public String getCode()
    {
        return this.code;
    }

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

    /**
     * <p>
     * TODO: Model Documentation for name
     * </p>
     * Get the name property.
     * @return String The value of name
     */
    @Column(name="NAME", nullable=false, insertable=true, updatable=true, length=50)
    @NotNull(message="name is required")
    @Size(max=50)
    public String getName()
    {
        return this.name;
    }

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

    /**
     * <p>
     * TODO: Model Documentation for grantInfoId
     * </p>
     * Get the grantInfoId property.
     * @return Long The value of grantInfoId
     */
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name="GRANT_INFO_ID", nullable=false, insertable=true, updatable=true)
    public Long getGrantInfoId()
    {
        return this.grantInfoId;
    }

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


    // ------------- 1 Relations ------------------
    /**
     * <p>
     * TODO: Model Documentation for sponsor
     * </p>
     * Get the sponsor
     * @return Sponsor
     */
    @ManyToOne(optional=false)
    @JoinColumn(name="SPONSOR_FK", nullable=false, insertable=true, updatable=true)
    public Sponsor getSponsor()
    {
        return this.sponsor;
    }

    /**
     * <p>
     * TODO: Model Documentation for sponsor
     * </p>
     * Set the sponsor
     * @param sponsorIn
     */
    public void setSponsor(Sponsor sponsorIn)
    {
        this.sponsor = sponsorIn;
    }

    // --------------- Constructors -----------------

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

    /**
     * Constructor with all updatable Entity attributes except auto incremented identifiers.
     *
     * @param code String value for the code property required=true lower=1
     * @param name String value for the name property required=true lower=1
     */
    public GrantInfo(String code, String name)
    {
        this.code = code;
        this.name = name;
    }


    /**
     * Constructor with all Entity attribute values and CMR relations.
     *
     * @param code String value for the code property
     * @param name String value for the name property
     * @param sponsor Sponsor value for the sponsor relation
     */
    public GrantInfo(String code, String name, Sponsor sponsor)
    {
        // 2 updatableAttributes
        setCode(code);
        setName(name);

        // 1 relations
        setSponsor(sponsor);
    }

    // -------- 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 GrantInfo))
        {
            return false;
        }
        final GrantInfo that = (GrantInfo)object;
        if (this.getGrantInfoId() == null || that.getGrantInfoId() == null || !this.getGrantInfoId().equals(that.getGrantInfoId()))
        {
            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 = 0;
        hashCode = 29 * hashCode + (getGrantInfoId() == null ? 0 : getGrantInfoId().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("GrantInfo(");
        sb.append(" code=").append(getCode());
        sb.append(" name=").append(getName());
        sb.append(" grantInfoId=").append(getGrantInfoId());
        sb.append(" sponsor=").append(getSponsor());
        sb.append(")");
        return sb.toString();
    }

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


}