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 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.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.java.lang.Object
clone()
Returns an exact copy of theTaxValue
(@see java.lang.Object#clone()).boolean
equals(java.lang.Object object)
double
getAppliedValue()
Returns the applied value of theTaxValue
.java.lang.String
getCode()
Returns the code of theTaxValue
.java.lang.String
getCurrencyIsoCode()
Returns the currency iso code of this absoluteTaxValue
ornull
if the tax value is relative.double
getValue()
Returns the value of theTaxValue
.int
hashCode()
boolean
isAbsolute()
Returnstrue
if thisTaxValue
is absolute.static TaxValue
parseTaxValue(java.lang.String str)
creates a tax value object from its string representation created via @see #toString().static java.util.Collection
parseTaxValueCollection(java.lang.String str)
creates a tax value collection from its string representation created via @see #toString(Collection).static double
sumAbsoluteTaxValues(java.util.Collection taxValues)
static double
sumAppliedTaxValues(java.util.Collection taxValues)
static double
sumRelativeTaxValues(java.util.Collection taxValues)
java.lang.String
toString()
Returns a string representation of this tax value.static java.lang.String
toString(java.util.Collection taxValueCollection)
creates the string representation of a collection of tax values.TaxValue
unapply()
-
-
-
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 absoluteTaxValue
ornull
if 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()
Returnstrue
if thisTaxValue
is absolute.- Returns:
true
if theTaxValue
is absolute.
-
clone
public java.lang.Object clone()
Returns an exact copy of theTaxValue
(@see java.lang.Object#clone()).- Overrides:
clone
in 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
-true
if the given price is net.- Returns:
- returns a copy of this
TaxValue
holding 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
-true
if given price is net,false
if 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:
toString
in 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.IllegalArgumentException
creates 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:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equals
in classjava.lang.Object
-
unapply
public TaxValue unapply()
- Returns:
- an exact copy of this tax value except its applied value.
-
-