org.davesag.generica.core
Class ShoppingItem

java.lang.Object
  extended byorg.davesag.generica.core.ShoppingItem
All Implemented Interfaces:
Persistable, Serializable

public class ShoppingItem
extends Object
implements Persistable, Serializable

This ShoppingItem bean represents the information we know about an item that can be bought by a user.

Since:
Generica 1.0
Version:
CVS Revision $Id: ShoppingItem.java,v 1.10 2004/04/08 13:19:08 davesag Exp $
Author:
Dave Sag http://www.davesag.com
See Also:
Serialized Form
Peristable via Hibernate:
table = "shopping_item"

Field Summary
protected  String theDescription
          a description of the item
protected  Money theDiscount
          The discount of the item.
protected  Long theId
          items's id used as a key by hibernate
protected  Money thePrice
          The total price of the item.
protected  Long theQuantity
          the number of these items
protected  Money theTax
          The total tax of the item.
protected  String theTaxNote
          note about the tax
protected  Money theUnitPrice
          The individual price of an item.
 
Constructor Summary
ShoppingItem()
          null constructor required by hibernate.
ShoppingItem(String description, Money unitprice, Money discount, Money tax, String taxnote)
          constructor with default quantity of 1.
 
Method Summary
 boolean equals(Object o)
          Tests if the supplied object is equal to this ShoppingItem.
 String getDescription()
          Returns a short description.
 Money getDiscount()
          Returns the discount.
 Integer getDiscountAmount()
          Returns the total discount.
 Long getId()
          Get the ShoppingItem's ID number.
 Money getPrice()
          Returns the unit price times the quanitity.
 Long getQuantity()
          Returns the number of these shopping items.
 Money getTax()
          Returns the total tax.
 Integer getTaxAmount()
          Returns the total tax.
 String getTaxNote()
          Returns the total taxNote.
 Money getUnitPrice()
          Returns the unit price.
 int hashcode()
          the hashcode.
 void setDescription(String desc)
          Set a short description of this ShoppingItem.
 void setDiscount(Money price)
          Set the discount of this ShoppingItem.
 void setDiscountAmount(Integer discount)
          Set the discount of this ShoppingItem.
protected  void setId(Long id)
          Sets the The ShoppingItem's ID number.
 void setQuantity(Long quantity)
          Set the number of these ShoppingItems.
 void setTax(Money tax)
          Set the tax of this ShoppingItem.
 void setTaxAmount(Integer tax)
          Set the tax of this ShoppingItem.
 void setTaxNote(String note)
          Set the taxNote of this ShoppingItem.
 void setTemplateId(Long id)
          Sets the The ShoppingItem's ID number directly.
 void setUnitPrice(Money price)
          Set the unit price of this ShoppingItem.
 String toString()
          a string of the shopping item.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

theId

protected Long theId
items's id used as a key by hibernate


theQuantity

protected Long theQuantity
the number of these items


theDescription

protected String theDescription
a description of the item


theDiscount

protected Money theDiscount
The discount of the item. This is computed by adding the price of the individual items.


thePrice

protected Money thePrice
The total price of the item. This is computed by adding the price of the individual items and is not persisted.


theUnitPrice

protected Money theUnitPrice
The individual price of an item.


theTax

protected Money theTax
The total tax of the item. This is computed by adding the tax of the individual items.


theTaxNote

protected String theTaxNote
note about the tax

Constructor Detail

ShoppingItem

public ShoppingItem()
null constructor required by hibernate.


ShoppingItem

public ShoppingItem(String description,
                    Money unitprice,
                    Money discount,
                    Money tax,
                    String taxnote)
constructor with default quantity of 1.

Parameters:
description - A description of the item.
discount - The discount on the item.
tax - The tax charged on the item.
taxnote - A not about the tax.
Method Detail

getId

public Long getId()
Get the ShoppingItem's ID number.

Specified by:
getId in interface Persistable
Returns:
The ShoppingItem's ID number.
Hibernate Unique ID Property:
generator-class = "identity"

setId

protected void setId(Long id)
Sets the The ShoppingItem's ID number.

Parameters:
id - The ID number to set.

setTemplateId

public void setTemplateId(Long id)
Sets the The ShoppingItem's ID number directly. This is only to be used when creating a template object, and is not to be used when creating actual objects that will be persisted.

Specified by:
setTemplateId in interface Persistable
Parameters:
id - The ID number to set.

getDescription

public String getDescription()
Returns a short description.

Returns:
A short description of this ShoppingItem. Can be null.
Hibernate Property:
length = "1024"

setDescription

public void setDescription(String desc)
Set a short description of this ShoppingItem.

Parameters:
desc - A description of this ShoppingItem.

getQuantity

public Long getQuantity()
Returns the number of these shopping items.

Returns:
The total number of these ShoppingItems.
Hibernate Property:

setQuantity

public void setQuantity(Long quantity)
Set the number of these ShoppingItems.

Parameters:
quantity - The number of these ShoppingItems.

getPrice

public Money getPrice()
Returns the unit price times the quanitity.

Returns:
The total price of this ShoppingItem.

getUnitPrice

public Money getUnitPrice()
Returns the unit price.

Returns:
The unit price of this ShoppingItem.
Hibernate Component:

setUnitPrice

public void setUnitPrice(Money price)
Set the unit price of this ShoppingItem.

Parameters:
price - The price of this ShoppingItem.

getDiscount

public Money getDiscount()
Returns the discount.

Returns:
The discount of this ShoppingItem.

setDiscount

public void setDiscount(Money price)
Set the discount of this ShoppingItem.

Parameters:
price - The discount of this ShoppingItem.

getTax

public Money getTax()
Returns the total tax.

Returns:
The total tax of this ShoppingItem.

setTax

public void setTax(Money tax)
Set the tax of this ShoppingItem. This is used by hibernate. The tax is normally computed by adding up the list of items.

Parameters:
tax - The tax of this ShoppingItem.

getTaxAmount

public Integer getTaxAmount()
Returns the total tax.

Returns:
The total tax of this ShoppingItem.
Hibernate Property:

setTaxAmount

public void setTaxAmount(Integer tax)
Set the tax of this ShoppingItem. This is used by hibernate. The tax is normally computed by adding up the list of items.

Parameters:
tax - The tax of this ShoppingItem.

getDiscountAmount

public Integer getDiscountAmount()
Returns the total discount.

Returns:
The total discount of this ShoppingItem.
Hibernate Property:

setDiscountAmount

public void setDiscountAmount(Integer discount)
Set the discount of this ShoppingItem. This is used by hibernate. The discount is normally computed by adding up the list of items.

Parameters:
discount - The discount on this ShoppingItem.

getTaxNote

public String getTaxNote()
Returns the total taxNote.

Returns:
The total taxNote of this ShoppingItem.
Hibernate Property:
length = "1024"

setTaxNote

public void setTaxNote(String note)
Set the taxNote of this ShoppingItem. This is used by hibernate. The taxNote is normally computed by adding up the list of items.

Parameters:
note - The taxNote of this ShoppingItem.

equals

public boolean equals(Object o)
Tests if the supplied object is equal to this ShoppingItem.

Parameters:
o - The object to test against this ShoppingItem. Must also be a ShoppingItem to make sense.
Returns:
true if the two shopping items have the same id.

toString

public String toString()
a string of the shopping item.

Returns:
a string of the shopping item.

hashcode

public int hashcode()
the hashcode.

Returns:
a valid hashcode for this item.


Dave Sag Generica API version 0.5.9 - (prerelease) Copyright 2003 - 2004 Dave Sag.