pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.component.shop.checkout
Class Price

java.lang.Object
  extended by org.torweg.pulse.util.entity.AbstractBasicEntity
      extended by org.torweg.pulse.component.shop.checkout.Price
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Price>

@Entity(name="checkout_Price")
public class Price
extends AbstractBasicEntity
implements java.lang.Comparable<Price>

The Price.

Version:
$Revision$
Author:
Christian Schatt
See Also:
Serialized Form

Constructor Summary
protected Price()
          Deprecated. 
  Price(java.math.BigDecimal a, TaxRate tr, java.util.Currency c, boolean nb)
          Creates a new Price from the given amount, TaxRate, Currency and net-based-flag.
  Price(Price p)
          The copy constructor.
  Price(Price p)
          Creates a new Price from the given org.torweg.pulse.component.shop.model.Price.
 
Method Summary
 Price add(Price p)
          Returns a new Price that is the sum of this Price and the given Price.
 int compareTo(Price p)
          Compares this Price with the given Price for order.
 Price divide(java.math.BigDecimal d)
          Returns a new Price that is the result of the division of this Price and the given divisor.
 boolean equals(java.lang.Object o)
          Determines whether the given Object is equal to this Price.
 java.math.BigDecimal getAmount()
          Returns the amount, which means either the net amount or the gross amount, according to the net-based-flag.
 java.util.Currency getCurrency()
          Returns the Currency.
 java.math.BigDecimal getGrossAmount()
          Returns the gross amount.
 java.math.BigDecimal getNetAmount()
          Returns the net amount.
 java.math.BigDecimal getTaxAmount()
          Returns the tax amount.
 TaxRate getTaxRate()
          Returns the TaxRate.
 int hashCode()
          Returns the hash code for this Price.
 boolean isNetBased()
          Returns the net-based-flag, indicating whether this Price is net based or gross based.
 Price multiply(java.math.BigDecimal m)
          Returns a new Price that is the product of this Price and the given multiplicand.
 Price subtract(Price p)
          Returns a new Price that is the difference of this Price and the given Price.
 java.lang.String toString()
          Returns the String representation of this Price.
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractBasicEntity
compareTo, getFullQualifiedClassNameJAXB, getId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Price

@Deprecated
protected Price()
Deprecated. 

The no-argument constructor used by JAXB and JPA.


Price

public Price(Price p)
The copy constructor.

Parameters:
p - the Price to be copied.
Throws:
java.lang.IllegalArgumentException - if the given Price is null.

Price

public Price(java.math.BigDecimal a, TaxRate tr,
             java.util.Currency c,
             boolean nb)
Creates a new Price from the given amount, TaxRate, Currency and net-based-flag.

Parameters:
a - the amount.
tr - the TaxRate.
c - the Currency.
nb - the net-based-flag.
Throws:
java.lang.IllegalArgumentException - if the given amount, TaxRate, or Currency is null.

Price

public Price(Price p)
Creates a new Price from the given org.torweg.pulse.component.shop.model.Price.

Parameters:
p - the org.torweg.pulse.component.shop.model.Price.
Throws:
java.lang.IllegalArgumentException - if the given org.torweg.pulse.component.shop.model.Price is null.
Method Detail

getAmount

public final java.math.BigDecimal getAmount()
Returns the amount, which means either the net amount or the gross amount, according to the net-based-flag.

Returns:
the amount.

getTaxRate

public final TaxRate getTaxRate()
Returns the TaxRate.

Returns:
the TaxRate.

getCurrency

public final java.util.Currency getCurrency()
Returns the Currency.

Returns:
the Currency.

isNetBased

public final boolean isNetBased()
Returns the net-based-flag, indicating whether this Price is net based or gross based.

Returns:
the net-based-flag.

getNetAmount

public final java.math.BigDecimal getNetAmount()
Returns the net amount.

Returns:
the net amount.

getGrossAmount

public final java.math.BigDecimal getGrossAmount()
Returns the gross amount.

Returns:
the gross amount.

getTaxAmount

public final java.math.BigDecimal getTaxAmount()
Returns the tax amount.

Returns:
the tax amount.

add

public final Price add(Price p)
Returns a new Price that is the sum of this Price and the given Price. The new Price will be net based, if this Price is net based.

Parameters:
p - the Price to be added to this Price.
Returns:
the new Price.
Throws:
java.lang.IllegalArgumentException - if the given Price is null or its TaxRate or its Currency is not equal to the TaxRate or the Currency of this Price .

subtract

public final Price subtract(Price p)
Returns a new Price that is the difference of this Price and the given Price. The new Price will be net based, if this Price is net based.

Parameters:
p - the Price to be subtracted from this Price.
Returns:
the new Price.
Throws:
java.lang.IllegalArgumentException - if the given Price is null or its TaxRate or its Currency is not equal to the TaxRate or the Currency of this Price.

multiply

public final Price multiply(java.math.BigDecimal m)
Returns a new Price that is the product of this Price and the given multiplicand.

Parameters:
m - the multiplicand.
Returns:
the new Price.
Throws:
java.lang.IllegalArgumentException - if the given multiplicand is null.

divide

public final Price divide(java.math.BigDecimal d)
Returns a new Price that is the result of the division of this Price and the given divisor.

Parameters:
d - the divisor.
Returns:
the new Price.
Throws:
java.lang.IllegalArgumentException - if the given divisor is null.

compareTo

public int compareTo(Price p)
Compares this Price with the given Price for order.

Specified by:
compareTo in interface java.lang.Comparable<Price>
Parameters:
p - the Price to be compared.
Returns:
a negative integer, zero, or a positive integer as this Price is less than, equal to, or greater than the given Price.
Throws:
java.lang.IllegalArgumentException - if the given Price is null.

toString

public java.lang.String toString()
Returns the String representation of this Price.

Overrides:
toString in class java.lang.Object
Returns:
the String representation.

equals

public boolean equals(java.lang.Object o)
Determines whether the given Object is equal to this Price. Two Prices are considered equal, if their amounts, TaxRates, Currencys and net-based-flags are equal.

Overrides:
equals in class AbstractBasicEntity
Parameters:
o - the Object.
Returns:
true, if the given Object is equal to this Price.

hashCode

public int hashCode()
Returns the hash code for this Price.

Overrides:
hashCode in class AbstractBasicEntity
Returns:
the hash code.
See Also:
AbstractBasicEntity.hashCode()