- java.lang.Object
-
- org.praxislive.core.Value
-
- org.praxislive.core.types.PNumber
-
- All Implemented Interfaces:
Comparable<PNumber>
public final class PNumber extends Value implements Comparable<PNumber>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.praxislive.core.Value
Value.Type<T extends Value>
-
-
Field Summary
Fields Modifier and Type Field Description static String
KEY_IS_INTEGER
static String
KEY_MAXIMUM
static String
KEY_MINIMUM
static String
KEY_SKEW
static int
MAX_VALUE
static int
MIN_VALUE
static PNumber
ONE
static PNumber
ZERO
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(PNumber o)
boolean
equals(Object obj)
Values must override the default equals method.boolean
equivalent(Value arg)
Indicates whether some other Value is equivalent to this one.static Optional<PNumber>
from(Value arg)
int
hashCode()
Values must override the default hashcode method.static ArgumentInfo
info()
static ArgumentInfo
info(double min, double max)
static ArgumentInfo
info(double min, double max, double skew)
static ArgumentInfo
integerInfo()
static ArgumentInfo
integerInfo(int min, int max)
boolean
isEmpty()
Check whether this Value is an empty value and has a zero length string representation.boolean
isInteger()
static PNumber
of(double val)
static PNumber
of(int val)
static PNumber
parse(String str)
int
toIntValue()
String
toString()
Values must override the default method to return a string representation that is immutable.double
value()
-
-
-
Field Detail
-
ONE
public static final PNumber ONE
-
ZERO
public static final PNumber ZERO
-
KEY_MINIMUM
public static final String KEY_MINIMUM
- See Also:
- Constant Field Values
-
KEY_MAXIMUM
public static final String KEY_MAXIMUM
- See Also:
- Constant Field Values
-
KEY_IS_INTEGER
public static final String KEY_IS_INTEGER
- See Also:
- Constant Field Values
-
KEY_SKEW
public static final String KEY_SKEW
- See Also:
- Constant Field Values
-
MAX_VALUE
public static final int MAX_VALUE
- See Also:
- Constant Field Values
-
MIN_VALUE
public static final int MIN_VALUE
- See Also:
- Constant Field Values
-
-
Method Detail
-
value
public double value()
-
toIntValue
public int toIntValue()
-
toString
public String toString()
Description copied from class:Value
Values must override the default method to return a string representation that is immutable.
-
hashCode
public int hashCode()
Description copied from class:Value
Values must override the default hashcode method.
-
equals
public boolean equals(Object obj)
Description copied from class:Value
Values must override the default equals method. This method should only returntrue
if the supplied Object is of the same type as the implementing Value. Values of an unknown type should be coerced before calling this method. This method does not have to guarantee thatthis.equals(that) == this.toString().equals(that.toString())
-
equivalent
public boolean equivalent(Value arg)
Description copied from class:Value
Indicates whether some other Value is equivalent to this one. UnlikeValue.equals(java.lang.Object)
this method is not symmetric - a value of a different type might be equivalent to this without the other type considering the reverse to be true.The default implementation uses identity or String equality.
- Overrides:
equivalent
in classValue
- Parameters:
arg
- value to test for equivalence- Returns:
- true if value is equivalent to this
-
isEmpty
public boolean isEmpty()
Description copied from class:Value
Check whether this Value is an empty value and has a zero length string representation. Subclasses may wish to override this for efficiency if the String representation is lazily created.
-
compareTo
public int compareTo(PNumber o)
- Specified by:
compareTo
in interfaceComparable<PNumber>
-
isInteger
public boolean isInteger()
-
of
public static PNumber of(double val)
-
of
public static PNumber of(int val)
-
parse
public static PNumber parse(String str) throws ValueFormatException
- Throws:
ValueFormatException
-
info
public static ArgumentInfo info()
-
info
public static ArgumentInfo info(double min, double max)
-
info
public static ArgumentInfo info(double min, double max, double skew)
-
integerInfo
public static ArgumentInfo integerInfo()
-
integerInfo
public static ArgumentInfo integerInfo(int min, int max)
-
-