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 likeadd(Percentage)andsubtract(Percentage). Besides there are some utility methods to ease working with that class:sum(Collection)andsplit(int).
-
-
Field Summary
Fields Modifier and Type Field Description static PercentageEIGHTYstatic PercentageFIFTYstatic PercentageFOURTYstatic PercentageHUNDREDstatic PercentageNINETYstatic PercentageSEVENTYstatic PercentageSEVENTYFIVEstatic PercentageSIXTYstatic PercentageTENstatic PercentageTHIRTYstatic PercentageTWENTYstatic PercentageTWENTYFIVEstatic PercentageZERO
-
Constructor Summary
Constructors Constructor Description Percentage(int rate)Creates a new percentage with the specified rate.Percentage(java.lang.String rate)Creates a new percentage with the specified rate.Percentage(java.math.BigDecimal rate)Creates a new percentage with the specified rate.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Percentageadd(Percentage percentage)Adds a percentage to current and returns the sum as new object.booleanequals(java.lang.Object obj)java.math.BigDecimalgetRate()Returns the percentage rate.inthashCode()java.util.List<Percentage>split(int parts)Splits this percentage into the specified number of parts.Percentagesubtract(Percentage percentage)Subtracts a percentage to current and returns the result as new object.static Percentagesum(Percentage... percent)Sums a list of percentages.static Percentagesum(java.util.Collection<Percentage> elements)Sums a list of percentages.java.lang.StringtoString()static java.util.List<Percentage>valueOf(int... rates)Creates a list percentages from the given int values.static java.util.List<Percentage>valueOf(java.lang.String... rates)Creates a list percentages from the given String values.static java.util.List<Percentage>valueOf(java.math.BigDecimal... rates)Creates a list percentages from the given BigDecimal values.
-
-
-
Field Detail
-
ZERO
public static final Percentage ZERO
-
TEN
public static final Percentage TEN
-
TWENTY
public static final Percentage TWENTY
-
TWENTYFIVE
public static final Percentage TWENTYFIVE
-
THIRTY
public static final Percentage THIRTY
-
FOURTY
public static final Percentage FOURTY
-
FIFTY
public static final Percentage FIFTY
-
SIXTY
public static final Percentage SIXTY
-
SEVENTY
public static final Percentage SEVENTY
-
SEVENTYFIVE
public static final Percentage SEVENTYFIVE
-
EIGHTY
public static final Percentage EIGHTY
-
NINETY
public static final Percentage NINETY
-
HUNDRED
public static final Percentage HUNDRED
-
-
Constructor Detail
-
Percentage
public Percentage(java.lang.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(java.math.BigDecimal rate)
Creates a new percentage with the specified rate.
-
-
Method Detail
-
valueOf
public static java.util.List<Percentage> valueOf(java.lang.String... rates)
Creates a list percentages from the given String values.
-
valueOf
public static java.util.List<Percentage> valueOf(int... rates)
Creates a list percentages from the given int values.
-
valueOf
public static java.util.List<Percentage> valueOf(java.math.BigDecimal... rates)
Creates a list percentages from the given BigDecimal values.
-
getRate
public java.math.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:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classAbstractAmount
-
sum
public static final Percentage sum(Percentage... percent)
Sums a list of percentages.
-
sum
public static final Percentage sum(java.util.Collection<Percentage> elements)
Sums a list of percentages.
-
split
public java.util.List<Percentage> split(int parts)
Splits this percentage into the specified number of parts.
-
-