Bicycle.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.bicycle;

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.Table;
import javax.validation.constraints.NotNull;

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

    // ----------- 4 Attribute Definitions ------------
    protected Long id;
    protected String type;
    protected int gears;
    protected String tyreTypes;

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

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

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

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

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

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

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

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


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

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

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



    // -------- 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 Bicycle))
        {
            return false;
        }
        final Bicycle that = (Bicycle)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 = 0;
        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("Bicycle(");
        sb.append(" id=").append(getId());
        sb.append(" type=").append(getType());
        sb.append(" gears=").append(getGears());
        sb.append(" tyreTypes=").append(getTyreTypes());
        sb.append(")");
        return sb.toString();
    }

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


}