CarTypeData.java

// license-header java merge-point
//
/**
 * @author Generated by ValueObject.vsl in andromda-java-cartridge on 08/18/2014 15:29:46-0400 Do not modify by hand!
 *
 * TEMPLATE:     ValueObject.vsl in andromda-java-cartridge.
 * MODEL CLASS:  org::andromda::samples::carrental::inventory::CarTypeData
 * STEREOTYPE:   ValueObject
 */
package org.andromda.samples.carrental.inventory;

import java.io.Serializable;
import java.util.Arrays;
import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * <p>
 * Represents the data of a Car Type
 * </p>
 */
public class CarTypeData
    implements Serializable, Comparable<CarTypeData>
{
    /** The serial version UID of this class. Needed for serialization. */
    private static final long serialVersionUID = -302470996046692449L;

    // Class attributes
    /**
     * <p>
     * TODO: Model Documentation for manufacter
     * </p>
     */
    protected String manufacter;
    /**
     * <p>
     * TODO: Model Documentation for identifier
     * </p>
     */
    protected String identifier;
    /**
     * <p>
     * TODO: Model Documentation for orderNo
     * </p>
     */
    protected String orderNo;
    /**
     * <p>
     * TODO: Model Documentation for comfortClass
     * </p>
     */
    protected String comfortClass;

    /** Default Constructor with no properties */
    public CarTypeData()
    {
        // Documented empty block - avoid compiler warning - no super constructor
    }

    /**
     * Constructor with all properties
     * @param manufacterIn String
     * @param identifierIn String
     * @param orderNoIn String
     * @param comfortClassIn String
     */
    public CarTypeData(final String manufacterIn, final String identifierIn, final String orderNoIn, final String comfortClassIn)
    {
        this.manufacter = manufacterIn;
        this.identifier = identifierIn;
        this.orderNo = orderNoIn;
        this.comfortClass = comfortClassIn;
    }

    /**
     * Copies constructor from other CarTypeData
     *
     * @param otherBean Cannot be <code>null</code>
     * @throws NullPointerException if the argument is <code>null</code>
     */
    public CarTypeData(final CarTypeData otherBean)
    {
        this.manufacter = otherBean.getManufacter();
        this.identifier = otherBean.getIdentifier();
        this.orderNo = otherBean.getOrderNo();
        this.comfortClass = otherBean.getComfortClass();
    }

    /**
     * Copies all properties from the argument value object into this value object.
     * @param otherBean Cannot be <code>null</code>
     */
    public void copy(final CarTypeData otherBean)
    {
        if (null != otherBean)
        {
            this.setManufacter(otherBean.getManufacter());
            this.setIdentifier(otherBean.getIdentifier());
            this.setOrderNo(otherBean.getOrderNo());
            this.setComfortClass(otherBean.getComfortClass());
        }
    }

    /**
     * <p>
     * TODO: Model Documentation for manufacter
     * </p>
     * Get the manufacter Attribute
     * @return manufacter String
     */
    public String getManufacter()
    {
        return this.manufacter;
    }

    /**
     * <p>
     * TODO: Model Documentation for manufacter
     * </p>
     * @param value String
     */
    public void setManufacter(final String value)
    {
        this.manufacter = value;
    }

    /**
     * <p>
     * TODO: Model Documentation for identifier
     * </p>
     * Get the identifier Attribute
     * @return identifier String
     */
    public String getIdentifier()
    {
        return this.identifier;
    }

    /**
     * <p>
     * TODO: Model Documentation for identifier
     * </p>
     * @param value String
     */
    public void setIdentifier(final String value)
    {
        this.identifier = value;
    }

    /**
     * <p>
     * TODO: Model Documentation for orderNo
     * </p>
     * Get the orderNo Attribute
     * @return orderNo String
     */
    public String getOrderNo()
    {
        return this.orderNo;
    }

    /**
     * <p>
     * TODO: Model Documentation for orderNo
     * </p>
     * @param value String
     */
    public void setOrderNo(final String value)
    {
        this.orderNo = value;
    }

    /**
     * <p>
     * TODO: Model Documentation for comfortClass
     * </p>
     * Get the comfortClass Attribute
     * @return comfortClass String
     */
    public String getComfortClass()
    {
        return this.comfortClass;
    }

    /**
     * <p>
     * TODO: Model Documentation for comfortClass
     * </p>
     * @param value String
     */
    public void setComfortClass(final String value)
    {
        this.comfortClass = value;
    }

    /**
     * @param object to compare this object against
     * @return boolean if equal
     * @see Object#equals(Object)
     */
    @Override
    public boolean equals(final Object object)
    {
        if (object==null || object.getClass() != this.getClass())
        {
             return false;
        }
        // Check if the same object instance
        if (object==this)
        {
            return true;
        }
        CarTypeData rhs = (CarTypeData) object;
        return new EqualsBuilder()
            .append(this.getManufacter(), rhs.getManufacter())
            .append(this.getIdentifier(), rhs.getIdentifier())
            .append(this.getOrderNo(), rhs.getOrderNo())
            .append(this.getComfortClass(), rhs.getComfortClass())
            .isEquals();
    }

    /**
     * @param object to compare this object against
     * @return int if equal
     * @see Comparable#compareTo(Object)
     */
    public int compareTo(final CarTypeData object)
    {
        if (object==null)
        {
            return -1;
        }
        // Check if the same object instance
        if (object==this)
        {
            return 0;
        }
        return new CompareToBuilder()
            .append(this.getManufacter(), object.getManufacter())
            .append(this.getIdentifier(), object.getIdentifier())
            .append(this.getOrderNo(), object.getOrderNo())
            .append(this.getComfortClass(), object.getComfortClass())
            .toComparison();
    }

    /**
     * @return int hashCode value
     * @see Object#hashCode()
     */
    @Override
    public int hashCode()
    {
        return new HashCodeBuilder(1249046965, -82296885)
            .append(this.getManufacter())
            .append(this.getIdentifier())
            .append(this.getOrderNo())
            .append(this.getComfortClass())
            .toHashCode();
    }

    /**
     * @return String representation of object
     * @see Object#toString()
     */
    @Override
    public String toString()
    {
        return new ToStringBuilder(this)
            .append("manufacter", this.getManufacter())
            .append("identifier", this.getIdentifier())
            .append("orderNo", this.getOrderNo())
            .append("comfortClass", this.getComfortClass())
            .toString();
    }

    /**
     * Compares the properties of this instance to the properties of the argument. This method will return
     * {@code false} as soon as it detects that the argument is {@code null} or not of the same type as
     * (or a sub-type of) this instance's type.
     *
     * <p/>For array, collection or map properties the comparison will be done one level deep, in other words:
     * the elements will be compared using the {@code equals()} operation.
     *
     * <p/>Note that two properties will be considered equal when both values are {@code null}.
     *
     * @param thatObject the object containing the properties to compare against this instance
     * @return this method will return {@code true} in case the argument has the same type as this class, or is a
     *      sub-type of this class and all properties as found on this class have equal values when queried on that
     *      argument instance; in all other cases this method will return {@code false}
     */
    public boolean equalProperties(final Object thatObject)
    {
        if (thatObject == null || !this.getClass().isAssignableFrom(thatObject.getClass()))
        {
            return false;
        }

        final CarTypeData that = (CarTypeData)thatObject;
        return
            equal(this.getManufacter(), that.getManufacter())
            && equal(this.getIdentifier(), that.getIdentifier())
            && equal(this.getOrderNo(), that.getOrderNo())
            && equal(this.getComfortClass(), that.getComfortClass())
        ;
    }

    /**
     * This is a convenient helper method which is able to detect whether or not two values are equal. Two values
     * are equal when they are both {@code null}, are arrays of the same length with equal elements or are
     * equal objects (this includes {@link java.util.Collection} and {@link java.util.Map} instances).
     *
     * <p/>Note that for array, collection or map instances the comparison runs one level deep.
     *
     * @param first the first object to compare, may be {@code null}
     * @param second the second object to compare, may be {@code null}
     * @return this method will return {@code true} in case both objects are equal as explained above;
     *      in all other cases this method will return {@code false}
     */
    protected static boolean equal(final Object first, final Object second)
    {
        final boolean equal;

        if (first == null)
        {
            equal = (second == null);
        }
        else if (first.getClass().isArray() && (second != null) && second.getClass().isArray())
        {
            equal = Arrays.equals((Object[])first, (Object[])second);
        }
        else // note that the following also covers java.util.Collection and java.util.Map
        {
            equal = first.equals(second);
        }

        return equal;
    }

    // CarTypeData value-object java merge-point
}