Enum Class Rounder.RoundingPolicy
java.lang.Object
java.lang.Enum<Rounder.RoundingPolicy>
com.northconcepts.datapipeline.transform.format.Rounder.RoundingPolicy
- All Implemented Interfaces:
Serializable,Comparable<Rounder.RoundingPolicy>,Constable
- Enclosing class:
Rounder
Rounding modes supported by
Rounder.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionBehaves the same asUPif the value is positive orDOWNif the value is negative.Discards the digits based on decimal places and never increments the digit prior to discarded fraction.Behaves the same asDOWNif the value is positive orUPif the value is negative.If discarded fraction is > 0.5, then behaves asUP, otherwise, behaves asDOWNIf the digit to the left of the discarded fraction is odd, behaves asHALF_UP, otherwise, behaves asHALF_DOWNIf the digit to the left of the discarded fraction is odd, behaves asHALF_DOWN, otherwise, behaves asHALF_UP.If discarded fraction is ≥ 0.5, then behaves asUP, otherwise, behaves asDOWNIf value is double, returns the same value.Discards the digits based on decimal places and always increments the digit prior to discarded fraction. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the matching legacyBigDecimalrounding constant, such asROUND_UP(8 for HALF_ODD, which has none).static Rounder.RoundingPolicyReturns the enum constant of this class with the specified name.static Rounder.RoundingPolicy[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
UP
Discards the digits based on decimal places and always increments the digit prior to discarded fraction. e.g. decimalPlaces = 2, then 7896.102 --> 7896.11 -
DOWN
Discards the digits based on decimal places and never increments the digit prior to discarded fraction. e.g. decimalPlaces = 2, then 7896.102 --> 7896.10 -
CEILING
Behaves the same asUPif the value is positive orDOWNif the value is negative. -
FLOOR
Behaves the same asDOWNif the value is positive orUPif the value is negative. -
HALF_UP
If discarded fraction is ≥ 0.5, then behaves asUP, otherwise, behaves asDOWN -
HALF_DOWN
If discarded fraction is > 0.5, then behaves asUP, otherwise, behaves asDOWN -
HALF_EVEN
If the digit to the left of the discarded fraction is odd, behaves asHALF_UP, otherwise, behaves asHALF_DOWN -
HALF_ODD
If the digit to the left of the discarded fraction is odd, behaves asHALF_DOWN, otherwise, behaves asHALF_UP. This RoudingPolicy is only supported for double. BigDecimal invalid input: '&' BigInteger are not supported. -
UNNECESSARY
If value is double, returns the same value. For BigDecimal invalid input: '&' BigInteger type of values, if no rounding is required, returns the same value, and if rounding is required, anArithmeticExceptionis thrown.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getPolicy
public int getPolicy()Returns the matching legacyBigDecimalrounding constant, such asROUND_UP(8 for HALF_ODD, which has none).
-