abstract const classafMongo::Flag
sys::Obj afMongo::Flag
(Advanced) A Flag represents many states by setting and clearing bits on a Int.
Using Ints as flags is still valid, but the Flags class gives superior debugging info. An example Flags class:
const class MyFlags : Flag { static const MyFlags one := MyFlags(1, "one") static const MyFlags two := MyFlags(2, "two") static const MyFlags three := MyFlags(3, "three") static const MyFlags four := MyFlags(4, "four") new make(|This|? f := null) : super(f) { } new makeFromDefinition(Int flag, Str? name) : super(flag, name) { } }
Set and clear bits by using +
and -
operators:
(MyFlags.two + MyFlags.two) .toStr --> two (MyFlags.two - MyFlags.four).toStr --> two
Multiple flags may be set:
(MyFlags.one + MyFlags.four).toStr --> one|four (MyFlags.two + MyFlags.four).toStr --> two|four
Flags are automatically coalesced:
(MyFlags.one + MyFlags.three) .toStr --> three
Unknown flags are presented as numbers:
(MyFlags(16)) .toStr --> (18) (MyFlags(10)) .toStr --> two|(8) (MyFlags(27)) .toStr --> three|(8)|(16)
- containsAll
Bool containsAll(Flag flag)
Returns
true
if all the given flag values are set on this object.- containsAny
Bool containsAny(Flag flag)
Returns
true
if any of the given flag values are set on this object.- make
- minus
Removes Flag b. Shortcut is a - b.
- minusInt
@
Operator
This minusInt(Int b)Removes Flag b. Shortcut is a - b.
- name
Str name { private set }
- plus
Add Flag b. Shortcut is a + b.
- plusInt
Add Flag b. Shortcut is a + b.
- value
const Int value