Interface Bitmaskable

All Known Subinterfaces:
GroupedBitmaskable
All Known Implementing Classes:
DeviceOperatingState, GenericDeviceOperatingState, SkyCondition

public interface Bitmaskable
A standardized API for domain objects that can be represented in bitmask form.

A bitmask is a collection of on/off flags encoded as bits within an integer value.

Since:
1.50
Version:
1.1
Author:
matt
  • Field Details

    • SORT_BY_TYPE

      static final Comparator<Bitmaskable> SORT_BY_TYPE
      A comparator of Bitmaskable by their type (class name) then bit index, in ascending order.
      Since:
      1.1
  • Method Details

    • bitmaskBitOffset

      int bitmaskBitOffset()
      Get the bit offset.
      Returns:
      offset, starting from 0 for the right-most bit
    • bitmaskValue

      static int bitmaskValue(Set<? extends Bitmaskable> maskables)
      Get a bitmask value for a set of Bitmaskable objects.
      Parameters:
      maskables - the set of Bitmaskable objects (null allowed)
      Returns:
      a bitmask value of all bitmaskBitOffset() values of the given maskables
      See Also:
    • setForBitmask

      static <T extends Enum<T> & Bitmaskable> Set<T> setForBitmask(int mask, Class<T> clazz)
      Convert a bitmask value into a set of Bitmaskable objects.
      Type Parameters:
      T - the value type
      Parameters:
      mask - a bitmask value of a set of Bitmaskable objects
      clazz - the class of an enumeration of Bitmaskable objects
      Returns:
      an immutable set of Bitmaskable objects, never null
      See Also:
    • setForBitmask

      static <T extends Bitmaskable> Set<T> setForBitmask(int mask, T[] values)
      Convert a bitmask value into a set of Bitmaskable objects.
      Type Parameters:
      T - the value type
      Parameters:
      mask - a bitmask value of a set of Bitmaskable objects
      values - the complete set of possible Bitmaskable objects
      Returns:
      an immutable set of Bitmaskable objects, never null
      See Also: