|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.amis.utils.flag.Flag<TYPE> cz.cuni.amis.utils.flag.ReasonFlag<TYPE,REASON>
TYPE
- REASON
- public class ReasonFlag<TYPE,REASON>
Allows you to pass reasons of flag change along with new value of the flag.
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 ;)
Nested Class Summary |
---|
Nested classes/interfaces inherited from class cz.cuni.amis.utils.flag.Flag |
---|
Flag.DoInSync<T> |
Constructor Summary | |
---|---|
ReasonFlag()
Initialize the flag without 'initialValue', initial value will be null. |
|
ReasonFlag(TYPE initialValue)
Initialize the flag with 'initialValue'. |
Method Summary | |
---|---|
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. |
Methods inherited from class cz.cuni.amis.utils.flag.Flag |
---|
clearListeners, defreeze, freeze, getFlag, inSync, inSyncInner, isFrozen, isListenning, isNone, isOne, removeAllListeners, removeListener, setFlag, waitFor, waitFor, waitForChange, waitForChange |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface cz.cuni.amis.utils.flag.IFlag |
---|
clearListeners, defreeze, freeze, getFlag, inSync, isFrozen, isListenning, removeAllListeners, removeListener, setFlag |
Constructor Detail |
---|
public ReasonFlag()
public ReasonFlag(TYPE initialValue)
initialValue
- Method Detail |
---|
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>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |