com.retek.commons.util.type
Class Percent
java.lang.Object
com.retek.commons.util.type.Percent
- All Implemented Interfaces:
- java.lang.Comparable, java.io.Serializable
- public final class Percent
- extends java.lang.Object
- implements java.lang.Comparable, java.io.Serializable
A representation of a Percent intended for use in arithmetic manipulation of Monies and
Quantities.
Characteristics of this implementation .
- Percents are immutable
- Percents are non-negative, i.e. can only be zero, or positive.
- Percents can be greater than 100.
Retek Inc. Copyright (c) 2003
- See Also:
- Serialized Form
Constructor Summary |
Percent(java.math.BigDecimal value)
|
Percent(long value)
Convenience constructor for creating whole integer Percents, such as 50% |
Percent(java.lang.String value)
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
ONE_HUNDRED
public static final Percent ONE_HUNDRED
ZERO
public static final Percent ZERO
Percent
public Percent(java.math.BigDecimal value)
Percent
public Percent(java.lang.String value)
- Throws:
java.lang.NumberFormatException
- if value can't be parsed as a number.
Percent
public Percent(long value)
- Convenience constructor for creating whole integer Percents, such as 50%
isZero
public boolean isZero()
isPositive
public boolean isPositive()
add
public Percent add(Percent other)
difference
public Percent difference(Percent other)
- This method exists instead of a subtract method due to the design decision that
this class only represents non-negative percent values.
isGreaterThan
public boolean isGreaterThan(Percent that)
multiply
public Percent multiply(Percent other)
multiply
public java.math.BigDecimal multiply(java.math.BigDecimal bigDecimal)
toBigDecimal
public java.math.BigDecimal toBigDecimal()
toString
public java.lang.String toString()
toString
public java.lang.String toString(int decimalPlaces)
equals
public boolean equals(java.lang.Object other)
hashCode
public int hashCode()
compareTo
public int compareTo(java.lang.Object o)
- Specified by:
compareTo
in interface java.lang.Comparable
ratioAsPercent
public static Percent ratioAsPercent(java.math.BigDecimal numerator,
java.math.BigDecimal denominator)
Copyright © 2005 Retek Inc. All Rights Reserved.
- Generated at Fri, 01/21/2005 14:25