TrackAthlete.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 java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;

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

    // ----------- 1 Attribute Definitions ------------
    protected Long trackNumber;

    // --------- 1 Relationship Definitions -----------
    protected Set<Sponsor> sponsors = new HashSet<Sponsor>();

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

    // -------- 1 Attribute Accessors ----------
    /**
     * <p>
     * TODO: Model Documentation for trackNumber
     * </p>
     * Get the trackNumber property.
     * @return Long The value of trackNumber
     */
    @Column(name="TRACK_NUMBER", insertable=true, updatable=true)
    public Long getTrackNumber()
    {
        return this.trackNumber;
    }

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


    // ------------- 1 Relations ------------------
    /**
     * <p>
     * TODO: Model Documentation for sponsors
     * </p>
     * Get the sponsors Collection
     * @return Set<Sponsor>
     */
    @OneToMany(mappedBy="trackAthlete")
    public Set<Sponsor> getSponsors()
    {
        return this.sponsors;
    }

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

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

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

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

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

    /**
     * Constructor with all Entity attribute values and CMR relations.
     *
     * @param name String value for the name property
     * @param trackNumber Long value for the trackNumber property
     * @param sponsors Set<Sponsor> value for the sponsors relation
     */
    public TrackAthlete(String name, Long trackNumber, Set<Sponsor> sponsors)
    {
        // 2 updatableAttributes
        setName(name);
        setTrackNumber(trackNumber);

        // 1 relations
        setSponsors(sponsors);
    }

    // -------- 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 TrackAthlete))
        {
            return false;
        }
        final TrackAthlete that = (TrackAthlete)object;
        if (this.getNumber() == null || that.getNumber() == null || !this.getNumber().equals(that.getNumber()))
        {
            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 + (getNumber() == null ? 0 : getNumber().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("TrackAthlete(");
        sb.append(super.toString());
        sb.append(" trackNumber=").append(getTrackNumber());
        sb.append(" number=").append(getNumber());
        sb.append(" name=").append(getName());
        sb.append(")");
        return sb.toString();
    }


}