Package org.tensorics.core.quantity
Class ImmutableQuantifiedValue<V>
- java.lang.Object
-
- org.tensorics.core.quantity.ImmutableQuantifiedValue<V>
-
- Type Parameters:
V
- the type of the (numerical) scalar values.
- All Implemented Interfaces:
java.io.Serializable
,ErronousValue<V>
,Quantified
,QuantifiedValue<V>
,ValidityAware
public final class ImmutableQuantifiedValue<V> extends java.lang.Object implements QuantifiedValue<V>
Groups a value together with its base. Additionally an error and a validity flag can be provided. If the latter two are not present explicitely given, then the validity will betrue
and the (optional) error will not be present.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
com.google.common.base.Optional<V>
error()
Retrieve the error of the scalarint
hashCode()
static <V> ImmutableQuantifiedValue<V>
of(V value, Unit unit)
java.lang.String
toString()
Unit
unit()
Retrieves the base of the entityjava.lang.Boolean
validity()
Retrieves the validity flag of the object.V
value()
ImmutableQuantifiedValue<V>
withError(com.google.common.base.Optional<V> newError)
ImmutableQuantifiedValue<V>
withError(V newError)
ImmutableQuantifiedValue<V>
withValidity(boolean newValidity)
-
-
-
Method Detail
-
of
public static <V> ImmutableQuantifiedValue<V> of(V value, Unit unit)
-
withValidity
public ImmutableQuantifiedValue<V> withValidity(boolean newValidity)
-
withError
public ImmutableQuantifiedValue<V> withError(com.google.common.base.Optional<V> newError)
-
withError
public ImmutableQuantifiedValue<V> withError(V newError)
-
value
public V value()
- Specified by:
value
in interfaceErronousValue<V>
-
unit
public Unit unit()
Description copied from interface:Quantified
Retrieves the base of the entity- Specified by:
unit
in interfaceQuantified
- Returns:
- the base of the quantified entity.
-
validity
public java.lang.Boolean validity()
Description copied from interface:ValidityAware
Retrieves the validity flag of the object.- Specified by:
validity
in interfaceValidityAware
- Returns:
true
if the content is valid,false
if it is not.
-
error
public com.google.common.base.Optional<V> error()
Description copied from interface:ErronousValue
Retrieve the error of the scalar- Specified by:
error
in interfaceErronousValue<V>
- Returns:
- the error
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-