Package com.exedio.cope.pattern
Class Price
- java.lang.Object
-
- com.exedio.cope.pattern.Price
-
- All Implemented Interfaces:
Serializable
,Comparable<Price>
public final class Price extends Object implements Serializable, Comparable<Price>
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Price
add(Price other)
BigDecimal
bigValue()
int
compareTo(Price other)
Price
divide(double other)
Price
divide(double other, RoundingMode roundingMode)
double
doubleValue()
boolean
equals(Object other)
boolean
equalsZero()
String
format(NumberFormat format)
Price
getGreater(Price other)
Deprecated.Usemax(Price)
insteadPrice
getLower(Price other)
Deprecated.Usemin(Price)
insteadboolean
greaterThan(Price other)
boolean
greaterThanOrEqual(Price other)
boolean
greaterThanOrEqualZero()
boolean
greaterThanZero()
Price
grossToNetPercent(int rate)
Price
grossToNetPercent(int rate, RoundingMode roundingMode)
Price
grossToTaxPercent(double rate)
Price
grossToTaxPercent(double rate, RoundingMode roundingMode)
Price
grossToTaxPercent(int rate)
Price
grossToTaxPercent(int rate, RoundingMode roundingMode)
int
hashCode()
boolean
lessThan(Price other)
boolean
lessThanOrEqual(Price other)
boolean
lessThanOrEqualZero()
boolean
lessThanZero()
Price
max(Price other)
Price
min(Price other)
Price
multiply(double other)
Price
multiply(double other, RoundingMode roundingMode)
Price
multiply(int other)
Price
negate()
Price
negative()
Deprecated.Usenegate()
insteadstatic Price
nullToZero(Price value)
static Price
parse(String source, DecimalFormat format)
static Price[]
splitProportionately(Price total, Price[] weights)
long
store()
int
storeIntExact()
static Price
storeOf(long store)
static Price
storeOf(Integer store)
static Price
storeOf(Long store)
Price
subtract(Price other)
String
toString()
Returns a string representation of this price.String
toStringShort()
Returns a string representation of this price without trailing zeros.static Price
valueOf(double value)
static Price
valueOf(double value, RoundingMode roundingMode)
static Price
valueOf(BigDecimal value)
static Price
valueOf(BigDecimal value, RoundingMode roundingMode)
-
-
-
Field Detail
-
MIN_VALUE
public static final Price MIN_VALUE
-
MAX_VALUE
public static final Price MAX_VALUE
-
ZERO
public static final Price ZERO
- See Also:
BigDecimal.ZERO
-
-
Method Detail
-
storeOf
public static Price storeOf(long store)
-
store
public long store()
-
storeIntExact
public int storeIntExact()
-
toString
public String toString()
Returns a string representation of this price. The result has trailing zeros, such as "1.20" or "1.00". If you don't want trailing zeros, usetoStringShort()
instead.
-
toStringShort
public String toStringShort()
Returns a string representation of this price without trailing zeros. If you want trailing zeros, usetoString()
instead.
-
format
public String format(NumberFormat format)
-
parse
public static Price parse(String source, DecimalFormat format) throws ParseException
- Throws:
ParseException
-
compareTo
public int compareTo(Price other)
- Specified by:
compareTo
in interfaceComparable<Price>
-
equalsZero
public boolean equalsZero()
-
lessThanZero
public boolean lessThanZero()
-
greaterThanZero
public boolean greaterThanZero()
-
lessThanOrEqualZero
public boolean lessThanOrEqualZero()
-
greaterThanOrEqualZero
public boolean greaterThanOrEqualZero()
-
lessThan
public boolean lessThan(Price other)
-
greaterThan
public boolean greaterThan(Price other)
-
lessThanOrEqual
public boolean lessThanOrEqual(Price other)
-
greaterThanOrEqual
public boolean greaterThanOrEqual(Price other)
-
min
public Price min(Price other)
- Returns:
- this if this price is lower than the other one; otherwise the other one
- See Also:
BigDecimal.min(BigDecimal)
-
max
public Price max(Price other)
- Returns:
- this if this price is greater than the other one; otherwise the other one
- See Also:
BigDecimal.max(BigDecimal)
-
negate
public Price negate()
- See Also:
BigDecimal.negate()
-
add
public Price add(Price other)
- See Also:
BigDecimal.add(BigDecimal)
-
subtract
public Price subtract(Price other)
- See Also:
BigDecimal.subtract(BigDecimal)
-
multiply
public Price multiply(int other)
- See Also:
BigDecimal.multiply(BigDecimal)
-
multiply
public Price multiply(double other)
- See Also:
BigDecimal.multiply(BigDecimal)
-
multiply
public Price multiply(double other, RoundingMode roundingMode)
- See Also:
BigDecimal.multiply(BigDecimal)
-
divide
public Price divide(double other)
- See Also:
BigDecimal.divide(BigDecimal)
-
divide
public Price divide(double other, RoundingMode roundingMode)
- See Also:
BigDecimal.divide(BigDecimal)
-
grossToNetPercent
public Price grossToNetPercent(int rate)
- Throws:
IllegalArgumentException
- if rate is negative
-
grossToNetPercent
public Price grossToNetPercent(int rate, RoundingMode roundingMode)
- Throws:
IllegalArgumentException
- if rate is negative
-
grossToTaxPercent
public Price grossToTaxPercent(int rate)
- Throws:
IllegalArgumentException
- if rate is negative
-
grossToTaxPercent
public Price grossToTaxPercent(double rate)
- Throws:
IllegalArgumentException
- if rate is negative
-
grossToTaxPercent
public Price grossToTaxPercent(int rate, RoundingMode roundingMode)
- Throws:
IllegalArgumentException
- if rate is negative
-
grossToTaxPercent
public Price grossToTaxPercent(double rate, RoundingMode roundingMode)
- Throws:
IllegalArgumentException
- if rate is negative
-
splitProportionately
public static Price[] splitProportionately(Price total, Price[] weights)
- Throws:
IllegalArgumentException
- if weights has length of 0.
-
valueOf
public static Price valueOf(double value)
- See Also:
BigDecimal.valueOf(double)
-
valueOf
public static Price valueOf(double value, RoundingMode roundingMode)
- See Also:
BigDecimal.valueOf(double)
-
doubleValue
public double doubleValue()
- See Also:
BigDecimal.doubleValue()
-
valueOf
public static Price valueOf(BigDecimal value)
-
valueOf
public static Price valueOf(BigDecimal value, RoundingMode roundingMode)
-
bigValue
public BigDecimal bigValue()
-
getLower
@Deprecated public Price getLower(Price other)
Deprecated.Usemin(Price)
instead
-
getGreater
@Deprecated public Price getGreater(Price other)
Deprecated.Usemax(Price)
instead
-
negative
@Deprecated public Price negative()
Deprecated.Usenegate()
instead
-
-