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

Source

Bool containsAll(Flag flag)

Returns true if all the given flag values are set on this object.

containsAny

Source

Bool containsAny(Flag flag)

Returns true if any of the given flag values are set on this object.

make

Source

new make(Int value, Str? name)

minus

Source

@Operator
This minus(Flag b)

Removes Flag b. Shortcut is a - b.

minusInt

Source

@Operator
This minusInt(Int b)

Removes Flag b. Shortcut is a - b.

name

Source

Str name { private set }

plus

Source

@Operator
This plus(Flag b)

Add Flag b. Shortcut is a + b.

plusInt

Source

@Operator
This plusInt(Int b)

Add Flag b. Shortcut is a + b.

value

Source

const Int value