Package foundation.omni
Class OmniDivisibleValue
java.lang.Object
java.lang.Number
javax.money.NumberValue
foundation.omni.OmniValue
foundation.omni.OmniDivisibleValue
- All Implemented Interfaces:
- Serializable,- Comparable<javax.money.NumberValue>
Numeric Value of Divisible Omni Token
 An Omni Divisible token is typically represented to the user as a decimal amount and hence
 you can have a fractional number of tokens. Internally it uses the same format as an indivisible token.
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final MathContextstatic final intstatic OmniDivisibleValuestatic final longstatic final BigDecimalstatic OmniDivisibleValuestatic final longstatic final BigDecimalstatic OmniDivisibleValueFields inherited from class foundation.omni.OmniValueMAX_WILLETTS, MIN_WILLETTS, willetts, willettsPerDivisible
- 
Method SummaryModifier and TypeMethodDescriptionConvert to aBigDecimalvalue.bytestatic voidcheckValue(long candidate) Make sure a long value is a valid value for OmniDivisibleValuestatic voidcheckValue(BigDecimal candidate) Make sure a BigDecimal value is a valid value for OmniDivisibleValuedoubleReturn a double value.doublebooleanfloatlonglongintintgetScale()intintValue()intlonglongminus(OmniDivisibleValue right) Return value in preferred number typestatic OmniDivisibleValueof(long amount) Create OmniDivisibleValue of the specified amountstatic OmniDivisibleValueof(BigDecimal amount) Create OmniDivisibleValue of the specified amountstatic OmniDivisibleValueofWilletts(long willetts) Create OmniDivisibleValue from willetts/internal/wire formatplus(OmniDivisibleValue right) round(MathContext mathContext) shortConvert toString.Convert toString.Convert toString.toString()Convert toString.Methods inherited from class foundation.omni.OmniValuecheckWillettValue, checkWillettValue, compareTo, getWilletts, hashCode, minus, multiply, numberValue, numberValueExact, of, of, of, of, of, of, ofWilletts, ofWilletts, plus
- 
Field Details- 
DEFAULT_CONTEXT
- 
DEFAULT_SCALEpublic static final int DEFAULT_SCALE- See Also:
 
- 
MIN_VALUE
- 
MAX_VALUE
- 
MIN_INT_VALUEpublic static final long MIN_INT_VALUE- See Also:
 
- 
MAX_INT_VALUEpublic static final long MAX_INT_VALUE- See Also:
 
- 
ZERO
- 
MIN
- 
MAX
 
- 
- 
Method Details- 
ofCreate OmniDivisibleValue of the specified amount- Parameters:
- amount- Number of Omni tokens
- Returns:
- OmniDivisibleValue representing amount
 
- 
ofCreate OmniDivisibleValue of the specified amount- Parameters:
- amount- Number of Omni tokens
- Returns:
- OmniDivisibleValue representing amount
 
- 
ofWillettsCreate OmniDivisibleValue from willetts/internal/wire format- Parameters:
- willetts- number of willetts
- Returns:
- OmniIndivisibleValue equal to number of willetts
 
- 
checkValueMake sure a BigDecimal value is a valid value for OmniDivisibleValue - Parameters:
- candidate- value to check
- Throws:
- ArithmeticException- if less than minimum or greater than maximum allowed value
 
- 
checkValueMake sure a long value is a valid value for OmniDivisibleValue - Parameters:
- candidate- value to check.
- Throws:
- ArithmeticException- if less than minimum or greater than maximum allowed value
 
- 
equals
- 
toStringConvert toString. Uses standard JVMtoString()formats. ForOmniDivisibleValueit is the same format asBigDecimal(this means"0E-8"forZERO.) ForOmniIndivisibleValueit is the same format asLong.
- 
toPlainStringConvert toString. ForOmniDivisibleValuethe same format asBigDecimal.toPlainString(). ForOmniIndivisibleValueit is the same asOmniIndivisibleValue.toString().- Specified by:
- toPlainStringin class- OmniValue
- Returns:
- Number as a string
 
- 
toJsonFormattedStringConvert toString. The required format for OmniValues in JSON. ForOmniDivisibleValuethere is always at least one place after the decimal point (e.g."0.0"). This allows humans and parsers to easily tellOmniDivisibleValues fromOmniIndivisibleValues. Note: The'.'separator is always used regardless of the currentLocale.- Specified by:
- toJsonFormattedStringin class- OmniValue
- Returns:
- Number as a string
 
- 
toFormattedStringConvert toString. A human-readable format using locale-specific place-separators.- Specified by:
- toFormattedStringin class- OmniValue
- Returns:
- Number as a string
 
- 
getPropertyType- Specified by:
- getPropertyTypein class- OmniValue
- Returns:
- property type
 
- 
getNumberType- Specified by:
- getNumberTypein class- OmniValue
 
- 
numberValueReturn value in preferred number type- Specified by:
- numberValuein class- OmniValue
- Returns:
- value as represented in best/preferred number type
 
- 
getPrecisionpublic int getPrecision()- Overrides:
- getPrecisionin class- OmniValue
 
- 
getScalepublic int getScale()
- 
intValueExactpublic int intValueExact()- Overrides:
- intValueExactin class- OmniValue
 
- 
longValueExactpublic long longValueExact()- Overrides:
- longValueExactin class- OmniValue
 
- 
doubleValueExactpublic double doubleValueExact()- Specified by:
- doubleValueExactin class- OmniValue
 
- 
round- Specified by:
- roundin class- javax.money.NumberValue
 
- 
getAmountFractionNumeratorpublic long getAmountFractionNumerator()- Overrides:
- getAmountFractionNumeratorin class- OmniValue
 
- 
getAmountFractionDenominatorpublic long getAmountFractionDenominator()- Overrides:
- getAmountFractionDenominatorin class- OmniValue
 
- 
byteValuepublic byte byteValue()
- 
shortValuepublic short shortValue()- Overrides:
- shortValuein class- OmniValue
 
- 
intValuepublic int intValue()
- 
longValuepublic long longValue()
- 
floatValuepublic float floatValue()- Overrides:
- floatValuein class- OmniValue
 
- 
doubleValuepublic double doubleValue()Return a double value. Warning: this will result in rounding errors. Only use this for applications like plotting data, never for anything that counts currency.- Specified by:
- doubleValuein class- OmniValue
- Returns:
- The value rounded to the nearest double.
 
- 
bigDecimalValueConvert to aBigDecimalvalue. This will be lossless. ForOmniIndivisibleValuetheBigDecimalvalue will be an integer, of course.- Specified by:
- bigDecimalValuein class- OmniValue
- Returns:
- the value
 
- 
plus
- 
minus
 
-