Class StructuredDecimal
java.lang.Object
net.visma.autopay.http.structured.StructuredItem
net.visma.autopay.http.structured.StructuredDecimal
- All Implemented Interfaces:
StructuredField
Class representing Structured Decimals. Also used as "bare" Decimal in Structured parameters.
-
Method Summary
Modifier and TypeMethodDescriptionReturnsBigDecimal
value of this Structured Decimaldouble
ReturnsDouble
value of this Structured Decimalboolean
Compares the specified object with this Structured Item for equality.int
hashCode()
Returns hash code for this Structured Item.static StructuredDecimal
of
(double value) Creates Structured Decimal of given value, without parameters.static StructuredDecimal
Creates Structured Decimal of given value, without parameters.static StructuredDecimal
of
(BigDecimal value) Creates Structured Decimal of given value, without parameters.static StructuredDecimal
Parses given string for Structured Decimal, according to the specificationstatic StructuredDecimal
withParams
(BigDecimal value, Map<String, ?> parameters) Creates Structured Decimal of given value and parametersstatic StructuredDecimal
withParams
(BigDecimal value, StructuredParameters parameters) Creates Structured Decimal of given value and parametersMethods inherited from class net.visma.autopay.http.structured.StructuredItem
bigDecimalParam, boolParam, bytesParam, doubleParam, intParam, longParam, parameters, serialize, stringParam, stringValue, toString
-
Method Details
-
of
Creates Structured Decimal of given value, without parameters.Stored value is modified version of provided value:
- Scale is set to 1 (one "fractional" zero) if there is no fractional part
- Extra trailing "fractional" zeros are removed
- If the "fractional" part is longer than 3 digits it is preserved in the stored value and rounded when serializing
- Parameters:
value
- Item value- Returns:
- Created Structured Decimal
- Throws:
IllegalArgumentException
- When provided value is outside the allowed range, which is ±999,999,999,999.999
-
of
Creates Structured Decimal of given value, without parameters.- Parameters:
value
- Item value- Returns:
- Created Structured Decimal
- Throws:
IllegalArgumentException
- When provided value is outside the allowed range- See Also:
-
of
Creates Structured Decimal of given value, without parameters.- Parameters:
value
- Item value- Returns:
- Created Structured Decimal
- Throws:
IllegalArgumentException
- When provided value is outside the allowed range- See Also:
-
withParams
Creates Structured Decimal of given value and parameters- Parameters:
value
- Item valueparameters
- Parameter map. For details, checkStructuredParameters.of(Map)
.- Returns:
- Created Structured Decimal
- Throws:
IllegalArgumentException
- When provided value is outside the allowed range- See Also:
-
withParams
Creates Structured Decimal of given value and parameters- Parameters:
value
- Item valueparameters
- Structured Parameters- Returns:
- Created Structured Decimal
- Throws:
IllegalArgumentException
- When provided value is outside the allowed range- See Also:
-
bigDecimalValue
ReturnsBigDecimal
value of this Structured Decimal- Returns:
- BigDecimal value represented by this Structured Decimal
-
doubleValue
public double doubleValue()ReturnsDouble
value of this Structured Decimal- Returns:
- Double value represented by this Structured Decimal
-
parse
Parses given string for Structured Decimal, according to the specification- Parameters:
httpHeader
- String to parse, e.g. HTTP header- Returns:
- Parsed Structured Decimal
- Throws:
StructuredException
- Thrown in case of malformatted string or wrong item type- See Also:
-
equals
Description copied from class:StructuredItem
Compares the specified object with this Structured Item for equality. Returns true if the given object is of the same class as this Item, it has the same value and properties.- Overrides:
equals
in classStructuredItem
- Parameters:
o
- Object to be compared with this Structured Item- Returns:
- True is specified object is equal to this Structured Item
-
hashCode
public int hashCode()Description copied from class:StructuredItem
Returns hash code for this Structured Item. The hash code is a combination of hash codes of Item parameters and Item value.- Overrides:
hashCode
in classStructuredItem
- Returns:
- The hash code for this Structured Item
-