CameraPK.java

// license-header java merge-point
/* Autogenerated by AndroMDA EntityCompositePK.vsl in andromda-ejb3-cartridge on 08/08/2014 12:21:04 - do not edit */
package org.andromda.demo.ejb3.camera;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * Composite primary key class for Camera entity bean.
 * <p>
 * TODO: Model Documentation for org.andromda.demo.ejb3.camera.Camera
 * </p>
 */
@Embeddable
public class CameraPK
    implements Serializable, Comparable<CameraPK>
{
    private static final long serialVersionUID = 1L;
    private String make;
    private String model;

    /**
     * Get the make property.
     * <p>
     * TODO: Model Documentation for make
     * </p>
     * @return String The value of make
     * owning=$property.otherEnd.owning optional=$property.optional $property.otherEnd.fulyQualifiedName many2One=$property.many2One target=$property.otherEnd.many2One
     */
    @Column(name="MAKE", nullable=false)
    public String getMake()
    {
        return this.make;
    }

    /**
     * Set the make property.
     * @param value the new value
     */
    public void setMake(String value)
    {
        this.make = value;
    }

    /**
     * Get the model property.
     * <p>
     * TODO: Model Documentation for model
     * </p>
     * @return String The value of model
     * owning=$property.otherEnd.owning optional=$property.optional $property.otherEnd.fulyQualifiedName many2One=$property.many2One target=$property.otherEnd.many2One
     */
    @Column(name="MODEL", nullable=false)
    public String getModel()
    {
        return this.model;
    }

    /**
     * Set the model property.
     * @param value the new value
     */
    public void setModel(String value)
    {
        this.model = value;
    }

    /**
     * Default empty constructor
     */
    public CameraPK()
    {
        // default empty constructor
    }

    /**
     * Implementation for the main constructor with all POJO identifier properties.
     *
     * @param make Value for the make property true
     * @param model Value for the model property false
     */
    public CameraPK(String make, String model)
    {
        setMake(make);
        setModel(model);
    }

    /**
     * Returns a hash code value for the object
     * @return int The hash code value
     * @see Object#hashCode
     */
    @Override
    public int hashCode()
    {
        int result = 0;
        result = 37*result + ((this.make != null) ? this.make.hashCode() : 0);
        result = 37*result + ((this.model != null) ? this.model.hashCode() : 0);
        return result;
    }

    /**
     * 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 (object == null)
        {
            return false;
        }
        if (object == this)
        {
            return true;
        }
        if (!(object instanceof CameraPK))
        {
            return false;
        }
        CameraPK pk = (CameraPK)object;
        return
             pk.make.equals(this.make)
            && pk.model.equals(this.model);
    }

    /**
     * @see Comparable#compareTo
     */
    @Override
    public int compareTo(CameraPK o)
    {
        int cmp = 0;
        if (this.getMake() != null)
        {
            cmp = this.getMake().compareTo(o.getMake());
        }
        if (this.getModel() != null)
        {
            cmp = (cmp != 0 ? cmp : this.getModel().compareTo(o.getModel()));
        }
        return cmp;
    }

    /**
     * Returns a String representation of the composite key object
     * @return String Textual representation of the object displaying name/value pairs for all properties
     * @see Object#toString
     */
    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append("CameraPK(");
        sb.append(" make=").append(getMake());
        sb.append(" model=").append(getModel());
        sb.append(")");
        return sb.toString();
    }
}