TYPE - REASON - public class ReasonFlag<TYPE,REASON> extends Flag<TYPE> implements IReasonFlag<TYPE,REASON>, Serializable
This extension of Flag is MAGICAL! And I mean it ... it is correct from the point of view of OOP (asfaik), but the Flag alone is complex class and we're trying to hack another parameter to the setFlag() method!
Anyway, it works as you would expect it to work ;)
Flag.DoInSync<T>| Constructor and Description |
|---|
ReasonFlag()
Initialize the flag without 'initialValue', initial value will be null.
|
ReasonFlag(TYPE initialValue)
Initialize the flag with 'initialValue'.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(FlagListener<TYPE> listener)
Use
ReasonFlagListener to get reasons or simple FlagListener to only receives
new values. |
void |
addStrongListener(FlagListener<TYPE> listener)
Use
ReasonFlagListener to get reasons or simple FlagListener to only receives
new values. |
ImmutableReasonFlag<TYPE,REASON> |
getImmutable() |
static void |
main(String[] args)
TEST METHOD!
|
void |
setFlag(TYPE newValue,
REASON reasonForChange)
Changes the flag and informs all listeners.
|
clearListeners, defreeze, freeze, getFlag, inSync, inSyncInner, isFrozen, isListenning, isNone, isOne, removeAllListeners, removeListener, setFlag, waitFor, waitFor, waitForChange, waitForChangeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclearListeners, defreeze, freeze, getFlag, inSync, isFrozen, isListenning, removeAllListeners, removeListener, setFlagpublic ReasonFlag()
public ReasonFlag(TYPE initialValue)
initialValue - public void setFlag(TYPE newValue, REASON reasonForChange)
Should not produce any dead-locks even though it is synchronized method.
setFlag in interface IReasonFlag<TYPE,REASON>newValue - InterruptedRuntimeException - if interrupted during the await on the freeze latchpublic void addStrongListener(FlagListener<TYPE> listener)
ReasonFlagListener to get reasons or simple FlagListener to only receives
new values.
FlagListener will be wrapped using ReasonFlagListener.FlagListenerAdapter
For more documentation see Flag
addStrongListener in interface IFlag<TYPE>addStrongListener in class Flag<TYPE>listener - public void addListener(FlagListener<TYPE> listener)
ReasonFlagListener to get reasons or simple FlagListener to only receives
new values.
FlagListener will be wrapped using ReasonFlagListener.FlagListenerAdapter
For more documentation see Flag.
WARNING:The listener is stored via weak-reference!
addListener in interface IFlag<TYPE>addListener in class Flag<TYPE>listener - public static void main(String[] args)
Test by eye :-(
public ImmutableReasonFlag<TYPE,REASON> getImmutable()
getImmutable in interface IFlag<TYPE>getImmutable in class Flag<TYPE>Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.