Package org.apache.juneau.internal
Class Flag
java.lang.Object
org.apache.juneau.internal.Flag
A simple settable boolean value.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Flagcreate()Creates a boolean value initialized tofalse .booleanSets the boolean value totrue and returns the value before it was set.booleanSets the boolean value tofalse and returns the value before it was set.Runs a snippet of code if the boolean value isfalse .Runs a snippet of code if the boolean value istrue .booleanisSet()Returnstrue if the boolean value istrue .booleanisUnset()Returnstrue if the boolean value isfalse .static Flagof(boolean value) Creates a boolean value with the specified initial state.set()Sets the boolean value totrue .setIf(boolean value) Sets the boolean value totrue if the value istrue .unset()Sets the boolean value tofalse .
-
Method Details
-
create
Creates a boolean value initialized tofalse .- Returns:
- A new boolean value.
-
of
Creates a boolean value with the specified initial state.- Parameters:
value- The initial state of the value.- Returns:
- A new boolean value.
-
ifSet
Runs a snippet of code if the boolean value istrue .Example:
BoolValue
flag = BoolValue.create (); ...flag .ifSet(()->doSomething ());- Parameters:
snippet- The snippet of code to run.- Returns:
- This object.
-
ifNotSet
Runs a snippet of code if the boolean value isfalse .Example:
BoolValue
flag = BoolValue.create (); ...flag .ifNotSet(()->doSomething ());- Parameters:
snippet- The snippet of code to run.- Returns:
- This object.
-
getAndSet
Sets the boolean value totrue and returns the value before it was set.- Returns:
- The previous value.
-
getAndUnset
Sets the boolean value tofalse and returns the value before it was set.- Returns:
- The previous value.
-
set
Sets the boolean value totrue .- Returns:
- This object.
-
unset
Sets the boolean value tofalse .- Returns:
- This object.
-
isSet
Returnstrue if the boolean value istrue .- Returns:
true if the boolean value istrue .
-
isUnset
Returnstrue if the boolean value isfalse .- Returns:
true if the boolean value isfalse .
-
setIf
Sets the boolean value totrue if the value istrue .- Parameters:
value- The value to set.- Returns:
- This object.
-