Rider.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.rider;
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.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.andromda.demo.ejb3.bicycle.Bicycle;
/**
* <p>
* TODO: Model Documentation for org.andromda.demo.ejb3.rider.Rider
* </p>
*
* Autogenerated POJO EJB class for Rider containing the
* bulk of the entity implementation.
*
* This is autogenerated by AndroMDA using the EJB3
* cartridge.
*
* DO NOT MODIFY this class.
*/
@Entity
@Table(name="RIDER")
@NamedQuery(name="Rider.findAll", query="SELECT r FROM Rider AS r")
public class Rider
implements Serializable, Comparable<Rider>{
private static final long serialVersionUID = -3109838952734753242L;
// ----------- 3 Attribute Definitions ------------
protected String name;
protected String gender;
protected Long riderId;
// --------- 1 Relationship Definitions -----------
protected Bicycle bicycle;
// ---- Manageable Display Attributes (Transient) -----
// -------- 3 Attribute Accessors ----------
/**
* <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 gender
* </p>
* Get the gender property.
* @return String The value of gender
*/
@Transient
public String getGender()
{
return this.gender;
}
/**
* <p>
* TODO: Model Documentation for gender
* </p>
* Set the gender property.
* @param value the new value
*/
public void setGender(String value)
{
this.gender = value;
}
/**
* <p>
* TODO: Model Documentation for riderId
* </p>
* Get the riderId property.
* @return Long The value of riderId
*/
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="RIDER_ID", nullable=false, insertable=true, updatable=true)
public Long getRiderId()
{
return this.riderId;
}
/**
* <p>
* TODO: Model Documentation for riderId
* </p>
* Set the riderId property.
* @param value the new value
*/
public void setRiderId(Long value)
{
this.riderId = value;
}
// ------------- 1 Relations ------------------
/**
* <p>
* TODO: Model Documentation for bicycle
* </p>
* Get the bicycle
* @return Bicycle
*/
@Transient
public Bicycle getBicycle()
{
return this.bicycle;
}
/**
* <p>
* TODO: Model Documentation for bicycle
* </p>
* Set the bicycle
* @param bicycleIn
*/
public void setBicycle(Bicycle bicycleIn)
{
this.bicycle = bicycleIn;
}
// --------------- Constructors -----------------
/**
* Default empty no-arg constructor
*/
public Rider()
{
// 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 gender String value for the gender property required=true lower=1
*/
public Rider(String name, String gender)
{
this.name = name;
this.gender = gender;
}
/**
* Constructor with all Entity attribute values and CMR relations.
*
* @param name String value for the name property
* @param gender String value for the gender property
* @param bicycle Bicycle value for the bicycle relation
*/
public Rider(String name, String gender, Bicycle bicycle)
{
// 2 updatableAttributes
setName(name);
setGender(gender);
// 1 relations
setBicycle(bicycle);
}
// -------- 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 Rider))
{
return false;
}
final Rider that = (Rider)object;
if (this.getRiderId() == null || that.getRiderId() == null || !this.getRiderId().equals(that.getRiderId()))
{
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 + (getRiderId() == null ? 0 : getRiderId().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("Rider(");
sb.append(" name=").append(getName());
sb.append(" gender=").append(getGender());
sb.append(" riderId=").append(getRiderId());
sb.append(" bicycle=").append(getBicycle());
sb.append(")");
return sb.toString();
}
/**
* @see Comparable#compareTo
*/
@Override
public int compareTo(Rider o)
{
int cmp = 0;
if (this.getRiderId() != null)
{
cmp = this.getRiderId().compareTo(o.getRiderId());
}
else
{
if (this.getName() != null)
{
cmp = (cmp != 0 ? cmp : this.getName().compareTo(o.getName()));
}
}
return cmp;
}
}