public class MeasureFactory extends Object
MeasureFactory provides some useful methods to build specific
Measures.| Constructor and Description |
|---|
MeasureFactory() |
| Modifier and Type | Method and Description |
|---|---|
<Value> PullMeasure<Value> |
createPullFromPush(PushMeasure<Value> push,
Value initialValue)
|
Map<String,PullMeasure<?>> |
createPullsFromFields(Object object)
Create
PullMeasures based on the fields available from an
instance, whatever it is. |
Map<String,PullMeasure<?>> |
createPullsFromGetters(Object object)
Create
PullMeasures based on the getters available from an
instance, whatever it is. |
<Value> PushMeasure<Value> |
createPushFromPull(PullMeasure<Value> pull,
long period)
Create a
PushMeasure which checks at regular intervals the value
of a PullMeasure. |
public <Value> PullMeasure<Value> createPullFromPush(PushMeasure<Value> push, Value initialValue)
PullMeasure to backup the last Value of a
PushMeasure. When the PushMeasure send a notification
with a given Value, this Value is stored into a variable
so that it can be retrieved at any time through the method
PullMeasure.get().push - a PushMeasure to backupinitialValue - the Value to return before the next notification of
the PushMeasure is sentPullMeasure allowing to retrieve the last value sent by
the PushMeasure, or the initial value if it did not send
anypublic <Value> PushMeasure<Value> createPushFromPull(PullMeasure<Value> pull, long period)
PushMeasure which checks at regular intervals the value
of a PullMeasure. If the value have changed since the last check
(or since the creation of the PushMeasure), a notification will
be generated by the PushMeasure with the new Value.Thread is run in
parallel to check regularly the Value modifications. If the
period is too big, you could miss relevant notifications, especially if
the PullMeasure change to a new Value and change back to
its previous Value between two consecutive checks. In such a
case, no notification will be sent because the Value during the
two checks is equal.pull - the PullMeasure to coverperiod - the number of milliseconds between each checkPushMeasure which will notify any change occurred on
the PullMeasure at the given frequencypublic Map<String,PullMeasure<?>> createPullsFromGetters(Object object)
PullMeasures based on the getters available from an
instance, whatever it is. The Class of the instance is analyzed
to retrieve its public methods and a PullMeasure is built for
each method which use a getter-like signature. The name of the method is
further exploited to identify the measure, such that the map returned use
the name of the method (without "get") as a key which maps to the
PullMeasure built from this method. The PullMeasure
itself is named by using the name of the method.object - the Object to coverMap which contains the names of the getter methods
and the corresponding PullMeasure built from thempublic Map<String,PullMeasure<?>> createPullsFromFields(Object object)
PullMeasures based on the fields available from an
instance, whatever it is. The Class of the instance is analyzed
to retrieve its public fields and a PullMeasure is built for each
of them. The name of the field is further exploited to identify the
measure, such that the map returned use the name of the field as a key
which maps to the PullMeasure built from this field. The
PullMeasure itself is named by using the name of the field.object - the Object to coverMap which contains the names of the getter methods
and the corresponding PullMeasure built from themCopyright © 2018. All rights reserved.