Package de.hybris.platform.util
Class TaxValue
- java.lang.Object
-
- de.hybris.platform.util.TaxValue
-
- All Implemented Interfaces:
PDTValue,java.io.Serializable,java.lang.Cloneable
- Direct Known Subclasses:
CachingFindTaxValueInfoStrategy.CachedTaxValue,Europe1PriceFactory.CachedTaxValue
public class TaxValue extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable, PDTValue
the string-storeable tax value object.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TaxValue(java.lang.String code, double value, boolean absolute, double appliedValue, java.lang.String currencyIsoCode)TaxValue(java.lang.String code, double value, boolean absolute, java.lang.String currencyIsoCode)constructs a new TaxValue object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TaxValueapply(double quantity, double price, int digits, boolean priceIsNet, java.lang.String currencyIsoCode)creates a copy of this tax value holding the applied value for a given price rounded to given digits.static java.util.Collectionapply(double quantity, double price, int digits, java.util.Collection taxValues, boolean priceIsNet, java.lang.String currencyIso)creates a collection of applied tax values for a given price and a tax value collection.java.lang.Objectclone()Returns an exact copy of theTaxValue(@see java.lang.Object#clone()).booleanequals(java.lang.Object object)doublegetAppliedValue()Returns the applied value of theTaxValue.java.lang.StringgetCode()Returns the code of theTaxValue.java.lang.StringgetCurrencyIsoCode()Returns the currency iso code of this absoluteTaxValueornullif the tax value is relative.doublegetValue()Returns the value of theTaxValue.inthashCode()booleanisAbsolute()Returnstrueif thisTaxValueis absolute.static TaxValueparseTaxValue(java.lang.String str)creates a tax value object from its string representation created via @see #toString().static java.util.CollectionparseTaxValueCollection(java.lang.String str)creates a tax value collection from its string representation created via @see #toString(Collection).static doublesumAbsoluteTaxValues(java.util.Collection taxValues)static doublesumAppliedTaxValues(java.util.Collection taxValues)static doublesumRelativeTaxValues(java.util.Collection taxValues)java.lang.StringtoString()Returns a string representation of this tax value.static java.lang.StringtoString(java.util.Collection taxValueCollection)creates the string representation of a collection of tax values.TaxValueunapply()
-
-
-
Constructor Detail
-
TaxValue
public TaxValue(java.lang.String code, double value, boolean absolute, java.lang.String currencyIsoCode)constructs a new TaxValue object.- Parameters:
code-value-absolute-currencyIsoCode-
-
TaxValue
public TaxValue(java.lang.String code, double value, boolean absolute, double appliedValue, java.lang.String currencyIsoCode)
-
-
Method Detail
-
getCode
public java.lang.String getCode()
Returns the code of theTaxValue.- Returns:
- the code of the
TaxValue.
-
getCurrencyIsoCode
public java.lang.String getCurrencyIsoCode()
Returns the currency iso code of this absoluteTaxValueornullif the tax value is relative.
-
getValue
public double getValue()
Returns the value of theTaxValue.
-
getAppliedValue
public double getAppliedValue()
Returns the applied value of theTaxValue.- Returns:
- the applied value of the
TaxValue.
-
isAbsolute
public boolean isAbsolute()
Returnstrueif thisTaxValueis absolute.- Returns:
trueif theTaxValueis absolute.
-
clone
public java.lang.Object clone()
Returns an exact copy of theTaxValue(@see java.lang.Object#clone()).- Overrides:
clonein classjava.lang.Object- Returns:
- an exact copy of the
TaxValue:
-
apply
public TaxValue apply(double quantity, double price, int digits, boolean priceIsNet, java.lang.String currencyIsoCode)
creates a copy of this tax value holding the applied value for a given price rounded to given digits.- Parameters:
price- the price to apply this tax value todigits- the digits to round the value to, if < 0 no rounding is donepriceIsNet-trueif the given price is net.- Returns:
- returns a copy of this
TaxValueholding the applied value for a given price rounded to given digits. - Since:
- 2.20
-
apply
public static java.util.Collection apply(double quantity, double price, int digits, java.util.Collection taxValues, boolean priceIsNet, java.lang.String currencyIso)creates a collection of applied tax values for a given price and a tax value collection. all resulting applied values prices are rounded to the given number of digits.- Parameters:
price- the price to apply these taxes todigits- the number of digits to round, if < 0 no rounding is donetaxValues- the collection of taxes to apply to the pricepriceIsNet-trueif given price is net,falseif given price is gross- Returns:
- the collection of applied tax values for the given parameters.
- Since:
- 2.20
-
sumRelativeTaxValues
public static double sumRelativeTaxValues(java.util.Collection taxValues)
-
sumAbsoluteTaxValues
public static double sumAbsoluteTaxValues(java.util.Collection taxValues)
-
sumAppliedTaxValues
public static double sumAppliedTaxValues(java.util.Collection taxValues)
-
toString
public java.lang.String toString()
Returns a string representation of this tax value. You may restore this object via @see #parseTaxValue(String).- Overrides:
toStringin classjava.lang.Object- Returns:
- string representation of this tax value.
-
toString
public static java.lang.String toString(java.util.Collection taxValueCollection)
creates the string representation of a collection of tax values. You may restore this collection via @see #parseTaxValueCollection(String).- Parameters:
taxValueCollection- a collection containing StandardTaxValues- Returns:
- string representation of a collection of tax values.
-
parseTaxValueCollection
public static java.util.Collection parseTaxValueCollection(java.lang.String str) throws java.lang.IllegalArgumentExceptioncreates a tax value collection from its string representation created via @see #toString(Collection).- Parameters:
str- string representation of aTaxValue.- Returns:
- a tax value collection from its string representation.
- Throws:
java.lang.IllegalArgumentException- if a parse error occurred
-
parseTaxValue
public static TaxValue parseTaxValue(java.lang.String str) throws java.lang.IllegalArgumentException
creates a tax value object from its string representation created via @see #toString().- Parameters:
str- string representation of aTaxValue.- Returns:
- a tax value object from its string representation.
- Throws:
java.lang.IllegalArgumentException- if the string is not valid
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
unapply
public TaxValue unapply()
- Returns:
- an exact copy of this tax value except its applied value.
-
-