org.flexiblepower.observation
T - The type of the value that is stored in the Observation.public class Observation<T> extends java.lang.Object
Observation is a measurement that has been done at a certain time. It is a tuple with the observedAt date
and the value (of dynamic type). This class provides a couple of helpful methods, like getting the value as a
Map when you don't know the type (see getValueMap().
For the helper methods, it is assumed that the value is a Java bean with getters.| Constructor and Description |
|---|
Observation(java.util.Date observedAt,
T value)
Creates a new
Observation for the given tuple. |
| Modifier and Type | Method and Description |
|---|---|
static <T> Observation<T> |
create(java.util.Date observedAt,
T value)
Creates a new
Observation for the given tuple. |
boolean |
equals(java.lang.Object obj) |
java.util.Date |
getObservedAt() |
T |
getValue() |
java.lang.Object |
getValue(java.lang.String name)
Tries to find a part of the value with the given name.
|
java.util.Map<java.lang.String,java.lang.Object> |
getValueMap()
Detects all the parts of the value, assuming a Java bean.
|
int |
hashCode() |
java.lang.String |
toString() |
public Observation(java.util.Date observedAt,
T value)
Observation for the given tuple.observedAt - The date at which the value has been observed.value - The valuejava.lang.NullPointerException - When either the observedAt or the value is null.public static <T> Observation<T> create(java.util.Date observedAt, T value)
Observation for the given tuple. This static helper method removes the need for specifying
T explicitly in java. This is exactly the same as calling
new Observation<T>(observedAt, value).T - The type of the value that is stored in the Observation.observedAt - The date at which the value has been observed.value - The valuepublic java.util.Date getObservedAt()
public T getValue()
public java.lang.Object getValue(java.lang.String name)
getValueMap().get(name).
Note: this is heavily dependent on reflection and therefore won't work on embedded Java versions.name - The name that will be used to find the getter method.null otherwise.public java.util.Map<java.lang.String,java.lang.Object> getValueMap()
Map with all the sub-values.public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object