OpenAPI 1.0

com.aquafold.openapi.type
Interface AQBigDecimalFactory


public interface AQBigDecimalFactory

This interface provides manipulation and validation functionality for BigDecimal data type.

An instance of this interface is available via aqua.type.bigDecimal alias.


Method Summary
 boolean isCloseTo(Object a, Object b, Object distance)
          Checks if two values are within the specified distance.
 boolean isGreater(Object a, Object b)
          Checks if the parameter value a is greater than the parameter value b.
 boolean isGreaterOrEqual(Object a, Object b)
          Checks if the parameter value a is greater than or equal to the parameter value b.
 boolean isInRange(Object value, Object min, Object max)
          Checks if the value is within a specified range, inclusive.
 boolean isLess(Object a, Object b)
          Checks if the parameter value a is less than the parameter value b.
 boolean isLessOrEqual(Object a, Object b)
          Checks if the parameter value a is less than or equal to the parameter value b.
 boolean isValid(String value)
          Interprets a specified value as a BigDecimal (using default platform locale).
 BigDecimal parse(Object value)
          Creates a BigDecimal instance assuming default platform locale.
 BigDecimal parse(String value, String pattern)
          Creates a BigDecimal instance using a specified pattern and locale.
 BigDecimal parse(String value, String pattern, String locale)
          Interprets a specified value as a BigDecimal using a specified pattern and locale.
 

Method Detail

parse

BigDecimal parse(Object value)
Creates a BigDecimal instance assuming default platform locale. Depending on the type of its argument, this method tries to make the most precise conversion.

If conversion is successful, the method returns the resulting BigDecimal object, otherwise it throws a RuntimeException.

Parameters:
value - A String or a number value.

parse

BigDecimal parse(String value,
                 String pattern)
Creates a BigDecimal instance using a specified pattern and locale.

If conversion is successful, the method returns the resulting BigDecimal object, otherwise it throws a RuntimeException.

Parameters:
value - String value to be parsed.
pattern - A DecimalFormat pattern.

parse

BigDecimal parse(String value,
                 String pattern,
                 String locale)
Interprets a specified value as a BigDecimal using a specified pattern and locale.

If conversion is successful, the method returns the resulting BigDecimal object, otherwise it throws a RuntimeException.

Parameters:
value - String value to be parsed.
pattern - A DecimalFormat pattern.
locale - Locale

isInRange

boolean isInRange(Object value,
                  Object min,
                  Object max)
Checks if the value is within a specified range, inclusive.

Parameters:
value - The value to in question.
min - Start of the range.
max - End of the range.
Returns:
true if value is within the range specified, inclusive of the min and max parameters.
Throws:
Exception - If any of the parameters cannot be converted to a big decimal.

isLess

boolean isLess(Object a,
               Object b)
Checks if the parameter value a is less than the parameter value b.

Parameters:
a - BigDecimal value to compare to.
b - BigDecimal value to compare with.
Returns:
true if the value of the parameter a is less than the value of the parameter b.
Throws:
Exception - If any of the parameters cannot be converted to a big decimal.

isLessOrEqual

boolean isLessOrEqual(Object a,
                      Object b)
Checks if the parameter value a is less than or equal to the parameter value b.

Parameters:
a - BigDecimal value to compare to.
b - BigDecimal value to compare with.
Returns:
true if the value of the parameter a is less or equal to the value of the parameter b.
Throws:
Exception - If any of the parameters cannot be converted to a big decimal.

isGreater

boolean isGreater(Object a,
                  Object b)
Checks if the parameter value a is greater than the parameter value b.

Parameters:
a - BigDecimal value to compare to.
b - BigDecimal value to compare with.
Returns:
true if the value of the parameter a is greater than the value of the parameter b.
Throws:
Exception - If any of the parameters cannot be converted to big decimal.

isGreaterOrEqual

boolean isGreaterOrEqual(Object a,
                         Object b)
Checks if the parameter value a is greater than or equal to the parameter value b.

Parameters:
a - BigDecimal value to compare to.
b - BigDecimal value to compare with.
Returns:
true if the value of the parameter a is greater or equal to the value of the parameter b.
Throws:
Exception - If any of the parameters cannot be converted to a big decimal.

isCloseTo

boolean isCloseTo(Object a,
                  Object b,
                  Object distance)
Checks if two values are within the specified distance. Since BigDecimal is inexact, mathematical operations may produce small errors, which make exact comparison fail.

Parameters:
a - The 1st big decimal value.
b - The 2nd big decimal value.
distance - The distance, as specified by the user to compare the difference between a and b.
Returns:
true the comparison is successful
Throws:
Exception - If any of the parameters cannot be converted to a big decimal.

isValid

boolean isValid(String value)
Interprets a specified value as a BigDecimal (using default platform locale).

If the value specified is a valid BigDecimal, true will be returned.

Parameters:
value - The string in specified.
Returns:
true if the string specified is a valid big decimal value.

OpenAPI 1.0


Copyright © 2010 AquaFold, Inc. All Rights Reserved. Use is subject to license terms.