Class Percentage

java.lang.Object
de.hybris.order.calculation.money.AbstractAmount
de.hybris.order.calculation.money.Percentage

public class Percentage extends AbstractAmount
Represents a relative amount to be used inside the calculation framework.

Provides common operations like add(Percentage) and subtract(Percentage).

Besides there are some utility methods to ease working with that class: sum(Collection) and split(int).

  • Field Details

  • Constructor Details

    • Percentage

      public Percentage(String rate)
      Creates a new percentage with the specified rate.
    • Percentage

      public Percentage(int rate)
      Creates a new percentage with the specified rate.
    • Percentage

      public Percentage(BigDecimal rate)
      Creates a new percentage with the specified rate.
  • Method Details

    • valueOf

      public static List<Percentage> valueOf(String... rates)
      Creates a list percentages from the given String values.
    • valueOf

      public static List<Percentage> valueOf(int... rates)
      Creates a list percentages from the given int values.
    • valueOf

      public static List<Percentage> valueOf(BigDecimal... rates)
      Creates a list percentages from the given BigDecimal values.
    • getRate

      public BigDecimal getRate()
      Returns the percentage rate.
    • add

      public Percentage add(Percentage percentage)
      Adds a percentage to current and returns the sum as new object.
    • subtract

      public Percentage subtract(Percentage percentage)
      Subtracts a percentage to current and returns the result as new object.
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class AbstractAmount
    • sum

      public static final Percentage sum(Percentage... percent)
      Sums a list of percentages.
    • sum

      public static final Percentage sum(Collection<Percentage> elements)
      Sums a list of percentages.
    • split

      public List<Percentage> split(int parts)
      Splits this percentage into the specified number of parts.