Vehicle.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.vehicle;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* <p>
* TODO: Model Documentation for org.andromda.demo.ejb3.vehicle.Vehicle
* </p>
*
* Autogenerated POJO EJB class for Vehicle containing the
* bulk of the entity implementation.
*
* This is autogenerated by AndroMDA using the EJB3
* cartridge.
*
* DO NOT MODIFY this class.
*/
@Entity
@Table(name="VEHICLE")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="TYPE", discriminatorType=DiscriminatorType.STRING)
@DiscriminatorValue("V")
@NamedQuery(name="Vehicle.findAll", query="SELECT v FROM Vehicle AS v")
public class Vehicle
implements Serializable, Comparable<Vehicle>{
private static final long serialVersionUID = -3087370246793082352L;
// ----------- 3 Attribute Definitions ------------
protected String license;
protected String make;
protected String model;
// -------- 3 Attribute Accessors ----------
/**
* <p>
* TODO: Model Documentation for license
* </p>
* Get the license property.
* @return String The value of license
*/
@Id
@Column(name="LICENSE", nullable=false, insertable=true, updatable=true)
@NotNull(message="license is required")
public String getLicense()
{
return this.license;
}
/**
* <p>
* TODO: Model Documentation for license
* </p>
* Set the license property.
* @param value the new value
*/
public void setLicense(String value)
{
this.license = value;
}
/**
* <p>
* TODO: Model Documentation for make
* </p>
* Get the make property.
* @return String The value of make
*/
@Column(name="MAKE", nullable=false, insertable=true, updatable=true, length=20)
@NotNull(message="make is required")
@Size(max=20)
public String getMake()
{
return this.make;
}
/**
* <p>
* TODO: Model Documentation for make
* </p>
* Set the make property.
* @param value the new value
*/
public void setMake(String value)
{
this.make = value;
}
/**
* <p>
* TODO: Model Documentation for model
* </p>
* Get the model property.
* @return String The value of model
*/
@Column(name="MODEL", nullable=false, insertable=true, updatable=true, length=20)
@NotNull(message="model is required")
@Size(max=20)
public String getModel()
{
return this.model;
}
/**
* <p>
* TODO: Model Documentation for model
* </p>
* Set the model property.
* @param value the new value
*/
public void setModel(String value)
{
this.model = value;
}
// ------------- 0 Relations ------------------
// --------------- Constructors -----------------
/**
* Default empty no-arg constructor
*/
public Vehicle()
{
// Default empty constructor
}
/**
* Constructor with all updatable Entity attributes except auto incremented identifiers.
*
* @param license String value for the license property required=true lower=1
* @param make String value for the make property required=true lower=1
* @param model String value for the model property required=true lower=1
*/
public Vehicle(String license, String make, String model)
{
this.license = license;
this.make = make;
this.model = model;
}
// -------- 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 Vehicle))
{
return false;
}
final Vehicle that = (Vehicle)object;
if (this.getLicense() == null || that.getLicense() == null || !this.getLicense().equals(that.getLicense()))
{
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 + (getLicense() == null ? 0 : getLicense().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("Vehicle(");
sb.append(" license=").append(getLicense());
sb.append(" make=").append(getMake());
sb.append(" model=").append(getModel());
sb.append(")");
return sb.toString();
}
/**
* @see Comparable#compareTo
*/
@Override
public int compareTo(Vehicle o)
{
int cmp = 0;
if (this.getLicense() != null)
{
cmp = this.getLicense().compareTo(o.getLicense());
}
else
{
if (this.getMake() != null)
{
cmp = (cmp != 0 ? cmp : this.getMake().compareTo(o.getMake()));
}
if (this.getModel() != null)
{
cmp = (cmp != 0 ? cmp : this.getModel().compareTo(o.getModel()));
}
}
return cmp;
}
}