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;
}
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;
}
- relates to
-
JDK-8241056 Add default methods to java.lang.Comparable interface
-
- Open
-