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

public static enum Rounder.RoundingPolicy extends Enum<Rounder.RoundingPolicy>
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 Constants
    Enum Constant
    Description
    Behaves the same as UP if the value is positive or DOWN if the value is negative.
    Discards the digits based on decimal places and never increments the digit prior to discarded fraction.
    Behaves the same as DOWN if the value is positive or UP if the value is negative.
    If discarded fraction is > 0.5, then behaves as UP, otherwise, behaves as DOWN
    If the digit to the left of the discarded fraction is odd, behaves as HALF_UP, otherwise, behaves as HALF_DOWN
    If the digit to the left of the discarded fraction is odd, behaves as HALF_DOWN, otherwise, behaves as HALF_UP.
    If discarded fraction is ≥ 0.5, then behaves as UP, otherwise, behaves as DOWN
    If 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 Type
    Method
    Description
    int
    Returns the matching legacy BigDecimal rounding constant, such as ROUND_UP (8 for HALF_ODD, which has none).
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • UP

      public static final Rounder.RoundingPolicy 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

      public static final Rounder.RoundingPolicy 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

      public static final Rounder.RoundingPolicy CEILING
      Behaves the same as UP if the value is positive or DOWN if the value is negative.
    • FLOOR

      public static final Rounder.RoundingPolicy FLOOR
      Behaves the same as DOWN if the value is positive or UP if the value is negative.
    • HALF_UP

      public static final Rounder.RoundingPolicy HALF_UP
      If discarded fraction is ≥ 0.5, then behaves as UP, otherwise, behaves as DOWN
    • HALF_DOWN

      public static final Rounder.RoundingPolicy HALF_DOWN
      If discarded fraction is > 0.5, then behaves as UP, otherwise, behaves as DOWN
    • HALF_EVEN

      public static final Rounder.RoundingPolicy HALF_EVEN
      If the digit to the left of the discarded fraction is odd, behaves as HALF_UP, otherwise, behaves as HALF_DOWN
    • HALF_ODD

      public static final Rounder.RoundingPolicy HALF_ODD
      If the digit to the left of the discarded fraction is odd, behaves as HALF_DOWN, otherwise, behaves as HALF_UP. This RoudingPolicy is only supported for double. BigDecimal invalid input: '&' BigInteger are not supported.
    • UNNECESSARY

      public static final Rounder.RoundingPolicy 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, an ArithmeticException is thrown.
  • Method Details

    • values

      public static Rounder.RoundingPolicy[] 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

      public static Rounder.RoundingPolicy valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • getPolicy

      public int getPolicy()
      Returns the matching legacy BigDecimal rounding constant, such as ROUND_UP (8 for HALF_ODD, which has none).