T
- The type of the Value
public final class Future<T> extends Object
Value
of a specific type.
Typically HasValue
will be false
until at a later point in time onValueDetermined(java.lang.Object)
is called and the Value
and HasValue
properties are being updated and the PropertyChanged
event is triggered.
Constructor and Description |
---|
Future() |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangedListener(IEventHandler<PropertyChangedEventArgs> propertyChangedEvent)
Adds the given listener for the
PropertyChanged event that occurs when a property value changes. |
T |
getValue()
The value of this future, which may only be queried if
HasValue yields true . |
boolean |
hasValue()
|
void |
onValueDetermined(T value)
Called when the
Value property of this future has been determined. |
void |
removePropertyChangedListener(IEventHandler<PropertyChangedEventArgs> propertyChangedEvent)
Removes the given listener for the
PropertyChanged event that occurs when a property value changes. |
public final void addPropertyChangedListener(IEventHandler<PropertyChangedEventArgs> propertyChangedEvent)
PropertyChanged
event that occurs when a property value changes.
This event will be triggered for HasValue
changes and changes of the Value
property. Note that if the determined future value is the same as the default, the event will only be triggered for the
HasValue
property.
propertyChangedEvent
- The listener to add.removePropertyChangedListener(IEventHandler)
public final T getValue()
HasValue
yields true
.IllegalStateException
- If this property is queried although HasValue
returns false
.public final boolean hasValue()
true
if this instance has been assigned a value; false
otherwise.public final void onValueDetermined(T value)
Value
property of this future has been determined.
This will set the HasValue
property to true
and assign the Value
property. Also the corresponding PropertyChanged
events will be
triggered if necessary.
value
- The value.public final void removePropertyChangedListener(IEventHandler<PropertyChangedEventArgs> propertyChangedEvent)
PropertyChanged
event that occurs when a property value changes.
This event will be triggered for HasValue
changes and changes of the Value
property. Note that if the determined future value is the same as the default, the event will only be triggered for the
HasValue
property.
propertyChangedEvent
- The listener to remove.addPropertyChangedListener(IEventHandler)