All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nz.co.senanque.pizzaorder.OrderItem Maven / Gradle / Ivy

Go to download

This is a plugin to Madura Objects. It provides a rules/constraint engine to assist with validation, deriving new values from user inputs (eg total of invoices entered on this customer) an manipulating metadata (eg because the amount is above X we make some field readonly). Note that the Java that is using the monitored objects is quite unaware of the rules layer implemented here. That means you can change rules without having to go back to your Java code, and it also means you don't have to wonder if everything implemented the same rules. Anything using that Java object has the rules (unless you turn them all off).

There is a newer version: 3.3.5
Show newest version
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 
// See http://java.sun.com/xml/jaxb 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2016.03.24 at 09:48:53 PM NZDT 
//


package nz.co.senanque.pizzaorder;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import nz.co.senanque.validationengine.ObjectMetadata;
import nz.co.senanque.validationengine.ValidationObject;
import nz.co.senanque.validationengine.ValidationSession;
import nz.co.senanque.validationengine.ValidationUtils;
import nz.co.senanque.validationengine.annotations.Digits;
import nz.co.senanque.validationengine.annotations.Label;
import nz.co.senanque.validationengine.annotations.Range;
import nz.co.senanque.validationengine.annotations.ReadOnly;
import org.jvnet.jaxb2_commons.lang.Equals;
import org.jvnet.jaxb2_commons.lang.EqualsStrategy;
import org.jvnet.jaxb2_commons.lang.HashCode;
import org.jvnet.jaxb2_commons.lang.HashCodeStrategy;
import org.jvnet.jaxb2_commons.lang.JAXBEqualsStrategy;
import org.jvnet.jaxb2_commons.lang.JAXBHashCodeStrategy;
import org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy;
import org.jvnet.jaxb2_commons.lang.ToString;
import org.jvnet.jaxb2_commons.lang.ToStringStrategy;
import org.jvnet.jaxb2_commons.locator.ObjectLocator;
import org.jvnet.jaxb2_commons.locator.util.LocatorUtils;


/**
 * 

Java class for OrderItem complex type. * *

The following schema fragment specifies the expected content contained within this class. * *

 * <complexType name="OrderItem">
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element name="id" type="{http://www.w3.org/2001/XMLSchema}long"/>
 *         <element name="parentid" type="{http://www.w3.org/2001/XMLSchema}long"/>
 *         <element name="amount" type="{http://www.w3.org/2001/XMLSchema}double"/>
 *         <element name="itemType" type="{http://www.senanque.co.nz/pizzaorder}ItemType"/>
 *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         <element name="description" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *       </sequence>
 *     </restriction>
 *   </complexContent>
 * </complexType>
 * 
* * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "OrderItem", propOrder = { "id", "parentid", "amount", "itemType", "name", "description" }) @XmlSeeAlso({ Bread.class, Extra.class, Drink.class, Dessert.class, Pizza.class }) @Entity(name = "OrderItem") @Table(name = "ORDERITEM") @Inheritance(strategy = InheritanceType.JOINED) public class OrderItem implements Serializable, ValidationObject, Equals, HashCode, ToString { protected long id; protected long parentid; @XmlElement(defaultValue = "0") protected double amount; @XmlElement(required = true) protected ItemType itemType; @XmlElement(required = true) protected String name; @XmlElement(required = true) protected String description; @XmlTransient protected ValidationSession m_validationSession; @XmlTransient protected ObjectMetadata m_metadata; @XmlTransient public final static String ID = "id"; @XmlTransient public final static String PARENTID = "parentid"; @XmlTransient public final static String AMOUNT = "amount"; @XmlTransient public final static String ITEMTYPE = "itemType"; @XmlTransient public final static String NAME = "name"; @XmlTransient public final static String DESCRIPTION = "description"; public OrderItem() { ValidationUtils.setDefaults(this); } /** * Gets the value of the id property. * */ @Id @Column(name = "ID", scale = 0) @Range(maxInclusive = "9223372036854775807", minInclusive = "-9223372036854775808") public long getId() { if (m_validationSession!= null) { m_validationSession.clean(this); } return id; } /** * Sets the value of the id property. * */ public void setId(long value) { getMetadata().removeUnknown("id"); if (m_validationSession!= null) { m_validationSession.set(this, "id", value, id); } this.id = value; if (m_validationSession!= null) { m_validationSession.invokeListeners(this, "id", value, id); } } /** * Gets the value of the parentid property. * */ @Basic @Column(name = "PARENTID", precision = 20, scale = 0) @Range(maxInclusive = "9223372036854775807", minInclusive = "-9223372036854775808") public long getParentid() { if (m_validationSession!= null) { m_validationSession.clean(this); } return parentid; } /** * Sets the value of the parentid property. * */ public void setParentid(long value) { getMetadata().removeUnknown("parentid"); if (m_validationSession!= null) { m_validationSession.set(this, "parentid", value, parentid); } this.parentid = value; if (m_validationSession!= null) { m_validationSession.invokeListeners(this, "parentid", value, parentid); } } /** * Gets the value of the amount property. * */ @Label(labelName = "Amount") @Digits(fractionalDigits = "2", integerDigits = "8") @Range(minInclusive = "5", maxInclusive = "1000") @ReadOnly @Basic @Column(name = "AMOUNT", precision = 20, scale = 10) public double getAmount() { if (m_validationSession!= null) { m_validationSession.clean(this); } return amount; } /** * Sets the value of the amount property. * */ public void setAmount(double value) { getMetadata().removeUnknown("amount"); if (m_validationSession!= null) { m_validationSession.set(this, "amount", value, amount); } this.amount = value; if (m_validationSession!= null) { m_validationSession.invokeListeners(this, "amount", value, amount); } } /** * Gets the value of the itemType property. * * @return * possible object is * {@link ItemType } * */ @Label(labelName = "item.type") @ReadOnly @Basic @Column(name = "ITEMTYPE", length = 255) @Enumerated(EnumType.STRING) public ItemType getItemType() { if (m_validationSession!= null) { m_validationSession.clean(this); } return itemType; } /** * Sets the value of the itemType property. * * @param value * allowed object is * {@link ItemType } * */ public void setItemType(ItemType value) { getMetadata().removeUnknown("itemType"); if (m_validationSession!= null) { m_validationSession.set(this, "itemType", value, itemType); } this.itemType = value; if (m_validationSession!= null) { m_validationSession.invokeListeners(this, "itemType", value, itemType); } } /** * Gets the value of the name property. * * @return * possible object is * {@link String } * */ @Label(labelName = "name") @ReadOnly @Basic @Column(name = "NAME_", length = 255) public String getName() { if (m_validationSession!= null) { m_validationSession.clean(this); } return name; } /** * Sets the value of the name property. * * @param value * allowed object is * {@link String } * */ public void setName(String value) { getMetadata().removeUnknown("name"); if (m_validationSession!= null) { m_validationSession.set(this, "name", value, name); } this.name = value; if (m_validationSession!= null) { m_validationSession.invokeListeners(this, "name", value, name); } } /** * Gets the value of the description property. * * @return * possible object is * {@link String } * */ @Label(labelName = "item.name") @ReadOnly @Basic @Column(name = "DESCRIPTION", length = 255) public String getDescription() { if (m_validationSession!= null) { m_validationSession.clean(this); } return description; } /** * Sets the value of the description property. * * @param value * allowed object is * {@link String } * */ public void setDescription(String value) { getMetadata().removeUnknown("description"); if (m_validationSession!= null) { m_validationSession.set(this, "description", value, description); } this.description = value; if (m_validationSession!= null) { m_validationSession.invokeListeners(this, "description", value, description); } } public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) { if (!(object instanceof OrderItem)) { return false; } if (this == object) { return true; } final OrderItem that = ((OrderItem) object); { long lhsId; lhsId = (true?this.getId(): 0L); long rhsId; rhsId = (true?that.getId(): 0L); if (!strategy.equals(LocatorUtils.property(thisLocator, "id", lhsId), LocatorUtils.property(thatLocator, "id", rhsId), lhsId, rhsId)) { return false; } } { long lhsParentid; lhsParentid = (true?this.getParentid(): 0L); long rhsParentid; rhsParentid = (true?that.getParentid(): 0L); if (!strategy.equals(LocatorUtils.property(thisLocator, "parentid", lhsParentid), LocatorUtils.property(thatLocator, "parentid", rhsParentid), lhsParentid, rhsParentid)) { return false; } } { double lhsAmount; lhsAmount = (true?this.getAmount(): 0.0D); double rhsAmount; rhsAmount = (true?that.getAmount(): 0.0D); if (!strategy.equals(LocatorUtils.property(thisLocator, "amount", lhsAmount), LocatorUtils.property(thatLocator, "amount", rhsAmount), lhsAmount, rhsAmount)) { return false; } } { ItemType lhsItemType; lhsItemType = this.getItemType(); ItemType rhsItemType; rhsItemType = that.getItemType(); if (!strategy.equals(LocatorUtils.property(thisLocator, "itemType", lhsItemType), LocatorUtils.property(thatLocator, "itemType", rhsItemType), lhsItemType, rhsItemType)) { return false; } } { String lhsName; lhsName = this.getName(); String rhsName; rhsName = that.getName(); if (!strategy.equals(LocatorUtils.property(thisLocator, "name", lhsName), LocatorUtils.property(thatLocator, "name", rhsName), lhsName, rhsName)) { return false; } } { String lhsDescription; lhsDescription = this.getDescription(); String rhsDescription; rhsDescription = that.getDescription(); if (!strategy.equals(LocatorUtils.property(thisLocator, "description", lhsDescription), LocatorUtils.property(thatLocator, "description", rhsDescription), lhsDescription, rhsDescription)) { return false; } } return true; } public boolean equals(Object object) { final EqualsStrategy strategy = JAXBEqualsStrategy.INSTANCE; return equals(null, null, object, strategy); } public String toString() { final ToStringStrategy strategy = JAXBToStringStrategy.INSTANCE; final StringBuilder buffer = new StringBuilder(); append(null, buffer, strategy); return buffer.toString(); } public StringBuilder append(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) { strategy.appendStart(locator, this, buffer); appendFields(locator, buffer, strategy); strategy.appendEnd(locator, this, buffer); return buffer; } public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) { { long theId; theId = (true?this.getId(): 0L); strategy.appendField(locator, this, "id", buffer, theId); } { long theParentid; theParentid = (true?this.getParentid(): 0L); strategy.appendField(locator, this, "parentid", buffer, theParentid); } { double theAmount; theAmount = (true?this.getAmount(): 0.0D); strategy.appendField(locator, this, "amount", buffer, theAmount); } { ItemType theItemType; theItemType = this.getItemType(); strategy.appendField(locator, this, "itemType", buffer, theItemType); } { String theName; theName = this.getName(); strategy.appendField(locator, this, "name", buffer, theName); } { String theDescription; theDescription = this.getDescription(); strategy.appendField(locator, this, "description", buffer, theDescription); } return buffer; } public int hashCode(ObjectLocator locator, HashCodeStrategy strategy) { int currentHashCode = 1; { long theId; theId = (true?this.getId(): 0L); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "id", theId), currentHashCode, theId); } { long theParentid; theParentid = (true?this.getParentid(): 0L); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "parentid", theParentid), currentHashCode, theParentid); } { double theAmount; theAmount = (true?this.getAmount(): 0.0D); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "amount", theAmount), currentHashCode, theAmount); } { ItemType theItemType; theItemType = this.getItemType(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "itemType", theItemType), currentHashCode, theItemType); } { String theName; theName = this.getName(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "name", theName), currentHashCode, theName); } { String theDescription; theDescription = this.getDescription(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "description", theDescription), currentHashCode, theDescription); } return currentHashCode; } public int hashCode() { final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE; return this.hashCode(null, strategy); } @Transient public ObjectMetadata getMetadata() { if (m_validationSession!= null) { m_validationSession.clean(this); } if (m_metadata == null) { m_metadata = new ObjectMetadata(); } return m_metadata; } @XmlTransient public void setValidationSession(ValidationSession validationSession) { m_validationSession = validationSession; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy