Registration.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.registration;

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.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

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

    // ----------- 5 Attribute Definitions ------------
    protected String mobileNumber;
    protected String name;
    protected String address;
    protected String description;
    protected Long registrationId;

    // --------- 1 Relationship Definitions -----------
    protected Profile profile;

    // ---- Manageable Display Attributes (Transient) -----
    protected String profileLabel;    // Manageable display attribute

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

    /**
     * <p>
     * TODO: Model Documentation for mobileNumber
     * </p>
     * Set the mobileNumber property.
     * @param value the new value
     */
    public void setMobileNumber(String value)
    {
        this.mobileNumber = 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 address
     * </p>
     * Get the address property.
     * @return String The value of address
     */
    @Column(name="ADDRESS", nullable=false, insertable=true, updatable=true, length=100)
    @NotNull(message="address is required")
    @Size(max=100)
    public String getAddress()
    {
        return this.address;
    }

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

    /**
     * <p>
     * TODO: Model Documentation for description
     * </p>
     * Get the description property.
     * @return String The value of description
     */
    @Column(name="DESCRIPTION", insertable=true, updatable=true, length=100)
    @Size(max=100)
    public String getDescription()
    {
        return this.description;
    }

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

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

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


    // ------------- 1 Relations ------------------
    /**
     * <p>
     * TODO: Model Documentation for profile
     * </p>
     * Get the profile
     * @return Profile
     */
    @OneToOne(mappedBy="registration")
    public Profile getProfile()
    {
        return this.profile;
    }

   /**
     * <p>
     * TODO: Model Documentation for profile
     * </p>
    * Set the profile
    * @param profileIn
    */
    public void setProfile(Profile profileIn)
    {
        this.profile = profileIn;
    }

    // -------- Manageable Attribute Display -----------
    /**
     * <p>
     * TODO: Model Documentation for profile
     * </p>
     * Get the profileLabel
     * @return String

     */
    @Transient
    public String getProfileLabel()
    {
        return this.profileLabel;
    }

    /**
     * <p>
     * TODO: Model Documentation for profile
     * </p>
     * Set the profileLabel
     * @param profileLabelIn
     */
    public void setProfileLabel (String profileLabelIn)
    {
        this.profileLabel = profileLabelIn;
    }

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

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

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

    /**
     * Constructor with required Entity attributes except auto incremented identifiers.
     *
     * @param mobileNumber Value for the mobileNumber property
     * @param name Value for the name property
     * @param address Value for the address property
     */
    public Registration(String mobileNumber, String name, String address)
    {
        this.mobileNumber = mobileNumber;
        this.name = name;
        this.address = address;
    }

    /**
     * Constructor with all Entity attribute values and CMR relations.
     *
     * @param mobileNumber String value for the mobileNumber property
     * @param name String value for the name property
     * @param address String value for the address property
     * @param description String value for the description property
     * @param profile Profile value for the profile relation
     */
    public Registration(String mobileNumber, String name, String address, String description, Profile profile)
    {
        // 4 updatableAttributes
        setMobileNumber(mobileNumber);
        setName(name);
        setAddress(address);
        setDescription(description);

        // 1 relations
        setProfile(profile);
    }

    /**
     * Constructor with required Entity attribute values and required CMR relations.
     *
     * @param mobileNumber String value for the mobileNumber property
     * @param name String value for the name property
     * @param address String value for the address property
     * @param profile Profile value for the profile relation
     */
    public Registration(String mobileNumber, String name, String address, Profile profile)
    {
        // 3 requiredAttributes
        setMobileNumber(mobileNumber);
        setName(name);
        setAddress(address);

        // 1 required association relations
        setProfile(profile);
    }

    // -------- 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 Registration))
        {
            return false;
        }
        final Registration that = (Registration)object;
        if (this.getRegistrationId() == null || that.getRegistrationId() == null || !this.getRegistrationId().equals(that.getRegistrationId()))
        {
            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 + (getRegistrationId() == null ? 0 : getRegistrationId().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("Registration(");
        sb.append(" mobileNumber=").append(getMobileNumber());
        sb.append(" name=").append(getName());
        sb.append(" address=").append(getAddress());
        sb.append(" description=").append(getDescription());
        sb.append(" registrationId=").append(getRegistrationId());
        sb.append(")");
        return sb.toString();
    }

    /**
     * @see Comparable#compareTo
     */
    @Override
    public int compareTo(Registration o)
    {
        int cmp = 0;
        if (this.getRegistrationId() != null)
        {
            cmp = this.getRegistrationId().compareTo(o.getRegistrationId());
        }
        else
        {
            if (this.getMobileNumber() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getMobileNumber().compareTo(o.getMobileNumber()));
            }
            if (this.getName() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getName().compareTo(o.getName()));
            }
            if (this.getAddress() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getAddress().compareTo(o.getAddress()));
            }
            if (this.getDescription() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getDescription().compareTo(o.getDescription()));
            }
        }
        return cmp;
    }


}