public final class Value extends Object implements Comparable<Value>
This class is immutable.
Constructor and Description |
---|
Value(Double value,
String unit)
Create a new immutable value with unit instance.
|
Value(String s)
Create a new value instance from a string of the form
"<number> <unit>", for instance "20.3 ft",
"1.5e-3m" etc.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Value v)
Compare this value to the specified value.
|
boolean |
equals(Object object) |
String |
getUnit()
Return unit of this instance.
|
Double |
getValue()
Return value of this instance.
|
int |
hashCode() |
String |
toString()
Return a string representation of this instance.
|
public Value(Double value, String unit)
value
- Value of this instance.
May be null to indicate absent.unit
- Unit of this instance. May be null to indicate
unitless or unknown.public Value(String s)
s
- String to create value from. Non-null.IllegalArgumentException
- If s is null.public Double getValue()
public String getUnit()
public int compareTo(Value v)
compareTo
in interface Comparable<Value>
v
- Value to compare to. Non-null.IllegalArgumentException
- If v is null.Copyright © 2023 Petroware AS - https://petroware.no