Athlete.java

  1. // license-header java merge-point
  2. //
  3. // Attention: Generated code! Do not modify by hand!
  4. // Generated by EntityEmbeddable.vsl in andromda-ejb3-cartridge on 08/08/2014 12:21:04.
  5. //
  6. package org.andromda.demo.ejb3.athlete;

  7. import java.io.Serializable;
  8. import javax.persistence.Column;
  9. import javax.persistence.DiscriminatorColumn;
  10. import javax.persistence.DiscriminatorType;
  11. import javax.persistence.DiscriminatorValue;
  12. import javax.persistence.Entity;
  13. import javax.persistence.GeneratedValue;
  14. import javax.persistence.GenerationType;
  15. import javax.persistence.Id;
  16. import javax.persistence.Inheritance;
  17. import javax.persistence.InheritanceType;
  18. import javax.persistence.NamedQuery;
  19. import javax.persistence.Table;
  20. import javax.validation.constraints.NotNull;
  21. import javax.validation.constraints.Size;

  22. /**
  23.  * <p>
  24.  * TODO: Model Documentation for org.andromda.demo.ejb3.athlete.Athlete
  25.  * </p>
  26.  *
  27.  * Autogenerated POJO EJB class for Athlete containing the
  28.  * bulk of the entity implementation.
  29.  *
  30.  * This is autogenerated by AndroMDA using the EJB3
  31.  * cartridge.
  32.  *
  33.  * DO NOT MODIFY this class.
  34.  */
  35. @Entity
  36. @Table(name="ATHLETE")
  37. @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
  38. @DiscriminatorColumn(name="TYPE", discriminatorType=DiscriminatorType.STRING)
  39. @DiscriminatorValue("A")
  40. @NamedQuery(name="Athlete.findAll", query="SELECT a FROM Athlete AS a")
  41. public class Athlete
  42.     implements Serializable, Comparable<Athlete>{
  43.     private static final long serialVersionUID = 706808658504640700L;

  44.     // ----------- 2 Attribute Definitions ------------
  45.     protected Long number;
  46.     protected String name;

  47.     // -------- 2 Attribute Accessors ----------
  48.     /**
  49.      * <p>
  50.      * TODO: Model Documentation for number
  51.      * </p>
  52.      * Get the number property.
  53.      * @return Long The value of number
  54.      */
  55.     @Id
  56.     @GeneratedValue(strategy=GenerationType.AUTO)
  57.     @Column(name="NUMBER", nullable=false, insertable=true, updatable=true)
  58.     public Long getNumber()
  59.     {
  60.         return this.number;
  61.     }

  62.     /**
  63.      * <p>
  64.      * TODO: Model Documentation for number
  65.      * </p>
  66.      * Set the number property.
  67.      * @param value the new value
  68.      */
  69.     public void setNumber(Long value)
  70.     {
  71.         this.number = value;
  72.     }

  73.     /**
  74.      * <p>
  75.      * TODO: Model Documentation for name
  76.      * </p>
  77.      * Get the name property.
  78.      * @return String The value of name
  79.      */
  80.     @Column(name="NAME", nullable=false, insertable=true, updatable=true, length=50)
  81.     @NotNull(message="name is required")
  82.     @Size(max=50)
  83.     public String getName()
  84.     {
  85.         return this.name;
  86.     }

  87.     /**
  88.      * <p>
  89.      * TODO: Model Documentation for name
  90.      * </p>
  91.      * Set the name property.
  92.      * @param value the new value
  93.      */
  94.     public void setName(String value)
  95.     {
  96.         this.name = value;
  97.     }


  98.     // ------------- 0 Relations ------------------
  99.     // --------------- Constructors -----------------

  100.     /**
  101.      * Default empty no-arg constructor
  102.      */
  103.     public Athlete()
  104.     {
  105.         // Default empty constructor
  106.     }

  107.     /**
  108.      * Constructor with all updatable Entity attributes except auto incremented identifiers.
  109.      *
  110.      * @param name String value for the name property required=true lower=1
  111.      */
  112.     public Athlete(String name)
  113.     {
  114.         this.name = name;
  115.     }



  116.     // -------- Common Methods -----------
  117.     /**
  118.      * Indicates if the argument is of the same type and all values are equal.
  119.      * @param object The target object to compare with
  120.      * @return boolean True if both objects a 'equal'
  121.      * @see Object#equals(Object)
  122.      */
  123.     @Override
  124.     public boolean equals(Object object)
  125.     {
  126.         if (null == object)
  127.         {
  128.             return false;
  129.         }
  130.         if (this == object)
  131.         {
  132.             return true;
  133.         }
  134.         if (!(object instanceof Athlete))
  135.         {
  136.             return false;
  137.         }
  138.         final Athlete that = (Athlete)object;
  139.         if (this.getNumber() == null || that.getNumber() == null || !this.getNumber().equals(that.getNumber()))
  140.         {
  141.             return false;
  142.         }
  143.         return true;
  144.     }

  145.     /**
  146.      * Returns a hash code value for the object
  147.      * @return int The hash code value
  148.      * @see Object#hashCode
  149.      */
  150.     @Override
  151.     public int hashCode()
  152.     {
  153.         int hashCode = 0;
  154.         hashCode = 29 * hashCode + (getNumber() == null ? 0 : getNumber().hashCode());

  155.         return hashCode;
  156.     }

  157.     /**
  158.      * Returns a String representation of the object
  159.      * @return String Textual representation of the object displaying name/value pairs for all attributes
  160.      * @see Object#toString
  161.      */
  162.     @Override
  163.     public String toString()
  164.     {
  165.         StringBuilder sb = new StringBuilder();
  166.         sb.append("Athlete(");
  167.         sb.append(" number=").append(getNumber());
  168.         sb.append(" name=").append(getName());
  169.         sb.append(")");
  170.         return sb.toString();
  171.     }

  172.     /**
  173.      * @see Comparable#compareTo
  174.      */
  175.     @Override
  176.     public int compareTo(Athlete o)
  177.     {
  178.         int cmp = 0;
  179.         if (this.getNumber() != null)
  180.         {
  181.             cmp = this.getNumber().compareTo(o.getNumber());
  182.         }
  183.         else
  184.         {
  185.             if (this.getName() != null)
  186.             {
  187.                 cmp = (cmp != 0 ? cmp : this.getName().compareTo(o.getName()));
  188.             }
  189.         }
  190.         return cmp;
  191.     }


  192. }