StoreItem.java
// license-header java merge-point
//
/**
* @author Generated by ValueObject.vsl in andromda-java-cartridge on 08/18/2014 15:30:42-0400 Do not modify by hand!
*
* TEMPLATE: ValueObject.vsl in andromda-java-cartridge.
* MODEL CLASS: my::onlinestore::purchase::StoreItem
* STEREOTYPE: ValueObject
*/
package my.onlinestore.purchase;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
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>
* TODO: Model Documentation for StoreItem
* </p>
*/
public class StoreItem
implements Serializable, Comparable<StoreItem>
{
/** The serial version UID of this class. Needed for serialization. */
private static final long serialVersionUID = -5764413783474605757L;
// Class attributes
/**
* <p>
* TODO: Model Documentation for title
* </p>
*/
protected String title;
/**
* <p>
* TODO: Model Documentation for publisher
* </p>
*/
protected String publisher;
/**
* <p>
* TODO: Model Documentation for available
* </p>
*/
protected boolean available;
/**
* boolean setter for primitive attribute, so we can tell if it's initialized
*/
protected boolean setAvailable = false;
/**
* <p>
* TODO: Model Documentation for id
* </p>
*/
protected String id;
/**
* <p>
* This column will not show up in the table because the tagged value on the 'itemList'
* page-variable does not include it in its value.
* </p>
*/
protected String hiddenColumn;
/**
* <p>
* TODO: Model Documentation for releaseDate
* </p>
*/
protected Date releaseDate;
/** Default Constructor with no properties */
public StoreItem()
{
// Documented empty block - avoid compiler warning - no super constructor
}
/**
* Constructor with all properties
* @param titleIn String
* @param publisherIn String
* @param availableIn boolean
* @param idIn String
* @param hiddenColumnIn String
* @param releaseDateIn Date
*/
public StoreItem(final String titleIn, final String publisherIn, final boolean availableIn, final String idIn, final String hiddenColumnIn, final Date releaseDateIn)
{
this.title = titleIn;
this.publisher = publisherIn;
this.available = availableIn;
this.setAvailable = true;
this.id = idIn;
this.hiddenColumn = hiddenColumnIn;
this.releaseDate = releaseDateIn;
}
/**
* Copies constructor from other StoreItem
*
* @param otherBean Cannot be <code>null</code>
* @throws NullPointerException if the argument is <code>null</code>
*/
public StoreItem(final StoreItem otherBean)
{
this.title = otherBean.getTitle();
this.publisher = otherBean.getPublisher();
this.available = otherBean.isAvailable();
this.setAvailable = true;
this.id = otherBean.getId();
this.hiddenColumn = otherBean.getHiddenColumn();
this.releaseDate = otherBean.getReleaseDate();
}
/**
* Copies all properties from the argument value object into this value object.
* @param otherBean Cannot be <code>null</code>
*/
public void copy(final StoreItem otherBean)
{
if (null != otherBean)
{
this.setTitle(otherBean.getTitle());
this.setPublisher(otherBean.getPublisher());
this.setAvailable(otherBean.isAvailable());
this.setAvailable = true;
this.setId(otherBean.getId());
this.setHiddenColumn(otherBean.getHiddenColumn());
this.setReleaseDate(otherBean.getReleaseDate());
}
}
/**
* <p>
* TODO: Model Documentation for title
* </p>
* Get the title Attribute
* @return title String
*/
public String getTitle()
{
return this.title;
}
/**
* <p>
* TODO: Model Documentation for title
* </p>
* @param value String
*/
public void setTitle(final String value)
{
this.title = value;
}
/**
* <p>
* TODO: Model Documentation for publisher
* </p>
* Get the publisher Attribute
* @return publisher String
*/
public String getPublisher()
{
return this.publisher;
}
/**
* <p>
* TODO: Model Documentation for publisher
* </p>
* @param value String
*/
public void setPublisher(final String value)
{
this.publisher = value;
}
/**
* <p>
* TODO: Model Documentation for available
* </p>
* Get the available Attribute
* @return available boolean
*/
public boolean isAvailable()
{
return this.available;
}
/**
* <p>
* TODO: Model Documentation for available
* </p>
* Duplicates isBoolean method, for use as Jaxb2 compatible object
* Get the available Attribute
* @return available boolean
*/
@Deprecated
public boolean getAvailable()
{
return this.available;
}
/**
* <p>
* TODO: Model Documentation for available
* </p>
* @param value boolean
*/
public void setAvailable(final boolean value)
{
this.available = value;
this.setAvailable = true;
}
/**
* Return true if the primitive attribute available is set, through the setter or constructor
* @return true if the attribute value has been set
*/
public boolean isSetAvailable()
{
return this.setAvailable;
}
/**
* <p>
* TODO: Model Documentation for id
* </p>
* Get the id Attribute
* @return id String
*/
public String getId()
{
return this.id;
}
/**
* <p>
* TODO: Model Documentation for id
* </p>
* @param value String
*/
public void setId(final String value)
{
this.id = value;
}
/**
* <p>
* This column will not show up in the table because the tagged value on the 'itemList'
* page-variable does not include it in its value.
* </p>
* Get the hiddenColumn Attribute
* @return hiddenColumn String
*/
public String getHiddenColumn()
{
return this.hiddenColumn;
}
/**
* <p>
* This column will not show up in the table because the tagged value on the 'itemList'
* page-variable does not include it in its value.
* </p>
* @param value String
*/
public void setHiddenColumn(final String value)
{
this.hiddenColumn = value;
}
/**
* <p>
* TODO: Model Documentation for releaseDate
* </p>
* Get the releaseDate Attribute
* @return releaseDate Date
*/
public Date getReleaseDate()
{
return this.releaseDate;
}
/**
* <p>
* TODO: Model Documentation for releaseDate
* </p>
* @param value Date
*/
public void setReleaseDate(final Date value)
{
this.releaseDate = 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;
}
StoreItem rhs = (StoreItem) object;
return new EqualsBuilder()
.append(this.getTitle(), rhs.getTitle())
.append(this.getPublisher(), rhs.getPublisher())
.append(this.isAvailable(), rhs.isAvailable())
.append(this.getId(), rhs.getId())
.append(this.getHiddenColumn(), rhs.getHiddenColumn())
.append(this.getReleaseDate(), rhs.getReleaseDate())
.isEquals();
}
/**
* @param object to compare this object against
* @return int if equal
* @see Comparable#compareTo(Object)
*/
public int compareTo(final StoreItem object)
{
if (object==null)
{
return -1;
}
// Check if the same object instance
if (object==this)
{
return 0;
}
return new CompareToBuilder()
.append(this.getTitle(), object.getTitle())
.append(this.getPublisher(), object.getPublisher())
.append(this.isAvailable(), object.isAvailable())
.append(this.getId(), object.getId())
.append(this.getHiddenColumn(), object.getHiddenColumn())
.append(this.getReleaseDate(), object.getReleaseDate())
.toComparison();
}
/**
* @return int hashCode value
* @see Object#hashCode()
*/
@Override
public int hashCode()
{
return new HashCodeBuilder(1249046965, -82296885)
.append(this.getTitle())
.append(this.getPublisher())
.append(this.isAvailable())
.append(this.getId())
.append(this.getHiddenColumn())
.append(this.getReleaseDate())
.toHashCode();
}
/**
* @return String representation of object
* @see Object#toString()
*/
@Override
public String toString()
{
return new ToStringBuilder(this)
.append("title", this.getTitle())
.append("publisher", this.getPublisher())
.append("available", this.isAvailable())
.append("id", this.getId())
.append("hiddenColumn", this.getHiddenColumn())
.append("releaseDate", this.getReleaseDate())
.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 StoreItem that = (StoreItem)thatObject;
return
equal(this.getTitle(), that.getTitle())
&& equal(this.getPublisher(), that.getPublisher())
&& equal(this.isAvailable(), that.isAvailable())
&& equal(this.getId(), that.getId())
&& equal(this.getHiddenColumn(), that.getHiddenColumn())
&& equal(this.getReleaseDate(), that.getReleaseDate())
;
}
/**
* 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;
}
// StoreItem value-object java merge-point
}