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 TotalPrice

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

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

The TotalPrice.

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

Nested Class Summary
static class TotalPrice.Quota
          The Quota.
 
Constructor Summary
protected TotalPrice()
          Deprecated. 
  TotalPrice(java.util.Collection<? extends Price> p, java.util.Currency c, boolean nb)
          Creates a new TotalPrice from the given Prices, Currency and net-based-flag.
  TotalPrice(java.util.Map<? extends TaxRate,? extends java.math.BigDecimal> aq, java.util.Currency c, boolean nb)
          Creates a new TotalPrice from the given amount quotas, Currency and net-based-flag.
  TotalPrice(Price p)
          Creates a new TotalPrice from the given Price.
  TotalPrice(ShoppingCart.Total t, java.util.Currency c, boolean nb)
          Deprecated. 
  TotalPrice(TotalPrice tp)
          The copy constructor.
 
Method Summary
 TotalPrice add(Price p)
          Returns a new TotalPrice that is the sum of this TotalPrice and the given Price.
 TotalPrice add(TotalPrice tp)
          Returns a new TotalPrice that is the sum of this TotalPrice and the given TotalPrice.
 int compareTo(TotalPrice tp)
          Compares this TotalPrice with the given TotalPrice for order.
 boolean equals(java.lang.Object o)
          Determines whether the given Object is equal to this TotalPrice.
 java.math.BigDecimal getAmount()
          Returns the amount.
 TotalPrice.Quota getAmountQuota(TaxRate tr)
          Returns the amount quota for the given TaxRate.
 java.util.SortedSet<TotalPrice.Quota> getAmountQuotas()
          Returns a SortedSet holding the amount quotas.
 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.
 TotalPrice.Quota getTaxQuota(TaxRate tr)
          Returns the tax quota for the given TaxRate.
 java.util.SortedSet<TotalPrice.Quota> getTaxQuotas()
          Returns the tax quotas.
 int hashCode()
          Returns the hash code for this TotalPrice.
 boolean isNetBased()
          Returns the net-based-flag, indicating whether this TotalPrice is net based or gross based.
 TotalPrice subtract(Price p)
          Returns a new TotalPrice that is the difference of this TotalPrice and the given Price.
 TotalPrice subtract(TotalPrice tp)
          Returns a new TotalPrice that is the difference of this TotalPrice and the given TotalPrice.
 java.lang.String toString()
          Returns the String representation of this TotalPrice.
 
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

TotalPrice

@Deprecated
protected TotalPrice()
Deprecated. 

The no-argument constructor used by JAXB and JPA.


TotalPrice

public TotalPrice(TotalPrice tp)
The copy constructor.

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

TotalPrice

public TotalPrice(Price p)
Creates a new TotalPrice from the given Price.

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

TotalPrice

public TotalPrice(java.util.Map<? extends TaxRate,? extends java.math.BigDecimal> aq,
                  java.util.Currency c,
                  boolean nb)
Creates a new TotalPrice from the given amount quotas, Currency and net-based-flag.

Parameters:
aq - the amount quotas.
c - the Currency.
nb - the net-based-flag.
Throws:
java.lang.IllegalArgumentException - if the given Map holding the amount quotas is null or empty or the given Currency is null.

TotalPrice

public TotalPrice(java.util.Collection<? extends Price> p,
                  java.util.Currency c,
                  boolean nb)
Creates a new TotalPrice from the given Prices, Currency and net-based-flag.

Parameters:
p - the Prices.
c - the Currency.
nb - the net-based-flag.
Throws:
java.lang.IllegalArgumentException - if the given Collection of Prices is null or empty, the given Currency is null or one of the given Prices' Currencys is not equal to the given Currency.

TotalPrice

@Deprecated
public TotalPrice(ShoppingCart.Total t,
                             java.util.Currency c,
                             boolean nb)
Deprecated. 

Do not use this constructor. it produces rounding errors!!! Creates a new TotalPrice from the given Total, Currency and net-based-flag.

Parameters:
t - the Total.
c - the Currency.
nb - the net-based-flag.
Throws:
java.lang.IllegalArgumentException - if the given Total or Currency is null.
Method Detail

getAmountQuotas

public final java.util.SortedSet<TotalPrice.Quota> getAmountQuotas()
Returns a SortedSet holding the amount quotas.

Returns:
the amount quotas.

getAmountQuota

public final TotalPrice.Quota getAmountQuota(TaxRate tr)
Returns the amount quota for the given TaxRate.

Parameters:
tr - the TaxRate.
Returns:
the amount quota.
Throws:
java.lang.IllegalArgumentException - if the given TaxRate is null.

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 TotalPrice is net based or gross based.

Returns:
the net-based-flag.

getAmount

public final java.math.BigDecimal getAmount()
Returns the amount.

Returns:
the amount.

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.

getTaxQuotas

public final java.util.SortedSet<TotalPrice.Quota> getTaxQuotas()
Returns the tax quotas.

Returns:
the tax quotas.

getTaxQuota

public final TotalPrice.Quota getTaxQuota(TaxRate tr)
Returns the tax quota for the given TaxRate.

Parameters:
tr - the TaxRate.
Returns:
the tax quota.
Throws:
java.lang.IllegalArgumentException - if the given TaxRate is null.

getTaxAmount

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

Returns:
the tax amount.

add

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

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

add

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

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

subtract

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

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

subtract

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

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

compareTo

public int compareTo(TotalPrice tp)
Compares this TotalPrice with the given TotalPrice for order.

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

toString

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

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 TotalPrice. Two TotalPrices are considered equal, if their amount quotas, 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 TotalPrice.

hashCode

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

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