Class TaxValue

java.lang.Object
de.hybris.platform.util.TaxValue
All Implemented Interfaces:
PDTValue, Serializable, Cloneable
Direct Known Subclasses:
CachingFindTaxValueInfoStrategy.CachedTaxValue, Europe1PriceFactory.CachedTaxValue

public class TaxValue extends Object implements Cloneable, Serializable, PDTValue
the string-storeable tax value object.
See Also:
  • Constructor Details

    • TaxValue

      public TaxValue(String code, double value, boolean absolute, String currencyIsoCode)
      constructs a new TaxValue object.

      Parameters:
      code -
      value -
      absolute -
      currencyIsoCode -
    • TaxValue

      public TaxValue(String code, double value, boolean absolute, double appliedValue, String currencyIsoCode)
  • Method Details

    • getCode

      public String getCode()
      Returns the code of the TaxValue.
      Returns:
      the code of the TaxValue.
    • getCurrencyIsoCode

      public String getCurrencyIsoCode()
      Returns the currency iso code of this absolute TaxValue or null if the tax value is relative.
    • getValue

      public double getValue()
      Returns the value of the TaxValue.
      Specified by:
      getValue in interface PDTValue
      Returns:
      the value of the TaxValue.
    • getAppliedValue

      public double getAppliedValue()
      Returns the applied value of the TaxValue.
      Returns:
      the applied value of the TaxValue.
    • isAbsolute

      public boolean isAbsolute()
      Returns true if this TaxValue is absolute.
      Returns:
      true if the TaxValue is absolute.
    • clone

      public Object clone()
      Returns an exact copy of the TaxValue (@see java.lang.Object#clone()).
      Overrides:
      clone in class Object
      Returns:
      an exact copy of the TaxValue:
    • apply

      public TaxValue apply(double quantity, double price, int digits, boolean priceIsNet, 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 to
      digits - the digits to round the value to, if < 0 no rounding is done
      priceIsNet - 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 Collection apply(double quantity, double price, int digits, Collection taxValues, boolean priceIsNet, 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 to
      digits - the number of digits to round, if < 0 no rounding is done
      taxValues - the collection of taxes to apply to the price
      priceIsNet - 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(Collection taxValues)
    • sumAbsoluteTaxValues

      public static double sumAbsoluteTaxValues(Collection taxValues)
    • sumAppliedTaxValues

      public static double sumAppliedTaxValues(Collection taxValues)
    • toString

      public String toString()
      Returns a string representation of this tax value. You may restore this object via @see #parseTaxValue(String).
      Overrides:
      toString in class Object
      Returns:
      string representation of this tax value.
    • toString

      public static String toString(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 Collection parseTaxValueCollection(String str) throws IllegalArgumentException
      creates a tax value collection from its string representation created via @see #toString(Collection).
      Parameters:
      str - string representation of a TaxValue.
      Returns:
      a tax value collection from its string representation.
      Throws:
      IllegalArgumentException - if a parse error occurred
    • parseTaxValue

      public static TaxValue parseTaxValue(String str) throws IllegalArgumentException
      creates a tax value object from its string representation created via @see #toString().
      Parameters:
      str - string representation of a TaxValue.
      Returns:
      a tax value object from its string representation.
      Throws:
      IllegalArgumentException - if the string is not valid
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • unapply

      public TaxValue unapply()
      Returns:
      an exact copy of this tax value except its applied value.