public final class NumberValue extends Object implements NumericalValue, Comparable<NumberValue>, Serializable
| Constructor and Description |
|---|
NumberValue(BigDecimal num) |
NumberValue(double num) |
NumberValue(long num) |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(ValueVisitor valueVisitor)
Performs some processing on a value.
|
NumberValueBuilder |
asBuilder() |
ValueComparator |
compare(Value o)
Compares this value and another numerically, or checks this number value
for membership in a value list.
|
int |
compareTo(NumberValue o) |
double |
doubleValue()
Gets this value as a double.
|
boolean |
equals(Object obj) |
String |
format(Format format)
Returns a string representing this value, formatted by the
provided
Format. |
BigDecimal |
getBigDecimal()
Gets this value as a
BigDecimal. |
String |
getFormatted()
Returns a string representing this value for display purposes.
|
static NumberValue |
getInstance(BigDecimal num) |
static NumberValue |
getInstance(double num)
Gets an instance of
NumberValue representing a
double. |
static NumberValue |
getInstance(long num) |
Number |
getNumber()
Gets this value as a number.
|
NumberValue |
getNumberValue()
Gets the number value component of this numerical value.
|
ValueType |
getType()
Returns this object's type, guaranteed not
null. |
int |
hashCode() |
long |
longValue() |
static NumberValue |
parse(String str)
Parses a number from a string.
|
NumberValue |
replace()
Returns a value from a cache that is equal to this one, if such a value
exists.
|
String |
toString() |
public NumberValue(long num)
public NumberValue(double num)
public NumberValue(BigDecimal num)
public static NumberValue parse(String str)
BigDecimal's string constructor.str - a string representing a number.NumberValue, or null if no number was
found in the string.public static NumberValue getInstance(double num)
NumberValue representing a
double.num - a double.NumberValue. Guaranteed not null.public static NumberValue getInstance(long num)
public static NumberValue getInstance(BigDecimal num)
public NumberValue replace()
Valuepublic int compareTo(NumberValue o)
compareTo in interface Comparable<NumberValue>public String getFormatted()
ValuegetFormatted in interface ValueString. Guaranteed not null.public String format(Format format)
ValueFormat.format in interface Valueformat - a Format. Passing in a null will
result in the same behavior as Value.getFormatted().String.public ValueType getType()
Valuenull.public double doubleValue()
NumericalValuedoubleValue in interface NumericalValuedouble.public long longValue()
public BigDecimal getBigDecimal()
NumericalValueBigDecimal.getBigDecimal in interface NumericalValueBigDecimal.public ValueComparator compare(Value o)
compare in interface Valueo - a Value.NumericalValue, returns null ValueComparator.GREATER_THAN,
ValueComparator.LESS_THAN or ValueComparator.EQUAL_TO
depending on whether this value is numerically greater than, less than or
equal to the value provided as argument. If the provided value is a
ValueList, returns ValueComparator.IN if this object is a
member of the list, or ValueComparator.NOT_IN if not. Otherwise,
returns ValueComparator.UNKNOWN.public Number getNumber()
NumericalValuegetNumber in interface NumericalValueNumber.public void accept(ValueVisitor valueVisitor)
ValueVisitableaccept in interface ValueVisitablepublic NumberValue getNumberValue()
NumericalValuegetNumberValue in interface NumericalValueNumberValue.public NumberValueBuilder asBuilder()
asBuilder in interface NumericalValueasBuilder in interface OrderedValueasBuilder in interface ValueCopyright © 2012–2018 Emory University. All rights reserved.