BigDecimal should have comparison methods that return a boolean

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Won't Fix
    • Priority: P4
    • None
    • Affects Version/s: 5.0
    • Component/s: core-libs
    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      Actually, it is not java.util, but I could not find java.math in the list.

      Add the following methods to java.math.BigDecimal.

      public boolean isGreaterThan(BigDecimal other)
      public boolean isGreaterOrEqual(BigDecimal other)
      public boolean isLessThan(BigDecimal other)
      public boolean isLessOrEqual(BigDecimal other)

      JUSTIFICATION :
      These methods makes the code more readable and enables the developer to use boolean methods similar to the default operators <, <=, >= and >, instead of the method compareTo().

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Methods that return a boolean to indicate if the value is greater than, greater or equal than, less than or less or equal than the supplied parameter.
      ACTUAL -
      There is no real actual behavior, except the method compareTo(BigDecimal other), which returns an integer.

      CUSTOMER SUBMITTED WORKAROUND :
      public boolean isGreaterThan(BigDecimal other)
      {
          return this.compareTo(other) > 0;
      }

      public boolean isGreaterOrEqual(BigDecimal other)
      {
          return this.compareTo(other) >= 0;
      }

      public boolean isLessThan(BigDecimal other)
      {
          return this.compareTo(other) < 0;
      }

      public boolean isLessOrEqual(BigDecimal other)
      {
          return this.compareTo(bd2) <= 0;
      }

            Assignee:
            Joe Darcy
            Reporter:
            Jon Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: