Camera.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.camera;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

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

    // ----------- 5 Attribute Definitions ------------
    protected double megapixels;
    protected boolean slr;
    protected Date released;

    // ----- Composite PK Accessors ------
    /**
     * Return the composite primary key for Camera
     * @return The composite primary key
     */
    @EmbeddedId
    @JoinColumns({
        @JoinColumn(name="MAKE", nullable=false),
        @JoinColumn(name="MODEL", nullable=false)
    })
    public CameraPK getPk()
    {
        return this.pk;
    }

    /**
     * Set the composite primary key for Camera
     * @param pkIn The composite primary key
     */
    public void setPk(CameraPK pkIn)
    {
        this.pk = pkIn;
    }

    // -------- 5 Attribute Accessors ----------
    /**
     * <p>
     * TODO: Model Documentation for megapixels
     * </p>
     * Get the megapixels property.
     * @return double The value of megapixels
     */
    @Column(name="MEGAPIXELS", nullable=false, insertable=true, updatable=true)
    @NotNull(message="megapixels is required")
    public double getMegapixels()
    {
        return this.megapixels;
    }

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

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

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

    /**
     * <p>
     * TODO: Model Documentation for released
     * </p>
     * Get the released property.
     * @return Date The value of released
     */
    @Column(name="RELEASED", insertable=true, updatable=true)
    @Temporal(TemporalType.TIMESTAMP)
    public Date getReleased()
    {
        return this.released;
    }

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


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

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

    /**
     * Constructor with all updatable Entity attributes except auto incremented identifiers.
     *
     * @param pk CameraPK The composite primary key class
     * @param megapixels double value for the megapixels property required=true lower=1
     * @param slr boolean value for the slr property required=true lower=1
     * @param released Date value for the released property required=false lower=0
     */
    public Camera(CameraPK pk, double megapixels, boolean slr, Date released)
    {
        setPk(pk);
        this.megapixels = megapixels;
        this.slr = slr;
        this.released = released;
    }

    /**
     * Constructor with required Entity attributes except auto incremented identifiers.
     *
     * @param pk CameraPK The composite primary key class
     * @param megapixels Value for the megapixels property
     * @param slr Value for the slr property
     */
    public Camera(CameraPK pk, double megapixels, boolean slr)
    {
        setPk(pk);
        this.megapixels = megapixels;
        this.slr = slr;
    }


    /**
     * Constructor with composite primary key arg only.
     *
     * @param pkIn CameraPK Composite primary key
     */
    public Camera(CameraPK pkIn)
    {
        this.pk = pkIn;
    }

    // -------- 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 Camera))
        {
            return false;
        }
        final Camera that = (Camera)object;
        if (this.getPk().getMake() == null || that.getPk().getMake() == null || !this.getPk().getMake().equals(that.getPk().getMake()))
        {
            return false;
        }
        if (this.getPk().getModel() == null || that.getPk().getModel() == null || !this.getPk().getModel().equals(that.getPk().getModel()))
        {
            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 + (getPk().getMake() == null ? 0 : getPk().getMake().hashCode());
        hashCode = 29 * hashCode + (getPk().getModel() == null ? 0 : getPk().getModel().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("Camera(");
        sb.append(this.pk);
        sb.append(" megapixels=").append(getMegapixels());
        sb.append(" slr=").append(isSlr());
        sb.append(" released=").append(getReleased());
        sb.append(")");
        return sb.toString();
    }

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


}