de.caff.util

## Class SimpleBitFlag

- java.lang.Object
- - de.caff.util.SimpleBitFlag

- All Implemented Interfaces:
    BitFlag

      public final class SimpleBitFlag
      extends java.lang.Object
      implements BitFlag

  A simple bit flag implementation.

  For efficiency reasons this class is not constructable, use the `get(int)` factory methods instead.

  This class is immutable.

  Author:
    Rammi

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `BitMask` | `clearIn(BitMask mask)` Clear this flag in the given bit mask.
    `static SimpleBitFlag` | `get(int index)` Get the simple bit flag for which the given index is set.
    `int` | `getBitPosition()` Get the bit position associated with this flag.
    `boolean` | `isSetIn(BitMask mask)` Is this flag set in the given mask?
    `BitMask` | `setIn(BitMask mask)` Set this flag in the given bit mask.
    `BitMask` | `toBitMask()` Convert this flag into a bit mask.
    `int` | `toInt()` Convert this flog into an integer bit mask.
    `long` | `toLong()` Convert this flog into a long bit mask.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### isSetIn

          public boolean isSetIn(@NotNull
                                 BitMask mask)

      Is this flag set in the given mask?
      Specified by:
        `isSetIn` in interface `BitFlag`
      Parameters:
        `mask` - bit mask
      Returns:
        `true`: if the flag is set
        `false`: if the flag is not set

    - #### setIn

          @NotNull
          public BitMask setIn(@NotNull
                                        BitMask mask)

      Set this flag in the given bit mask.
      Specified by:
        `setIn` in interface `BitFlag`
      Parameters:
        `mask` - bit mask
      Returns:
        new bit mask where this flag is set

    - #### clearIn

          @NotNull
          public BitMask clearIn(@NotNull
                                          BitMask mask)

      Clear this flag in the given bit mask.
      Specified by:
        `clearIn` in interface `BitFlag`
      Parameters:
        `mask` - bit mask
      Returns:
        new bit mask where this flag is cleared

    - #### toBitMask

          @NotNull
          public BitMask toBitMask()

      Convert this flag into a bit mask.
      Returns:
        bit mask

    - #### toInt

          public int toInt()

      Convert this flog into an integer bit mask.
      Returns:
        integer bit mask, possibly `0` if this flag is outside of 32 bit range range

    - #### toLong

          public long toLong()

      Convert this flog into a long bit mask.
      Returns:
        long bit mask, possibly `0` if this flag is outside of 64 bit range

    - #### getBitPosition

          public int getBitPosition()

      Get the bit position associated with this flag.
      Returns:
        bit position

    - #### get

          @NotNull
          public static SimpleBitFlag get(int index)

      Get the simple bit flag for which the given index is set.
      Parameters:
        `index` - bit flag index
      Returns:
        simple bit flag which has the given bit index set