Class BitFieldSet<E extends java.lang.Enum<E>>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>

    public class BitFieldSet<E extends java.lang.Enum<E>>
    extends java.util.AbstractSet<E>
    implements java.lang.Cloneable, java.io.Serializable
    Re-Implementation of RegularEnumSet class for EnumSet, for "regular sized" enum types (i.e., those with 64 or fewer enum constants)

    Modification allows access and manipulation of the bit mask for the elements so this class can be easily converted between long/int and BitFieldSet to use as efficient option flags in implementation but convenient enum sets for manipulation.

    If the Enum implements BitField then each field can have 1..N bits up to a maximum total of 64 bits per enum. The class provides methods for setting and getting values from these fields as long, int, short or byte values, either signed or unsigned.

    Since:
    1.5
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean add​(E e)
      Adds the specified element to this set if it is not already present.
      boolean add​(E... rest)  
      boolean add​(E e1, E e2)  
      boolean add​(E e1, E e2, E e3)  
      boolean add​(E e1, E e2, E e3, E e4)  
      boolean add​(E e1, E e2, E e3, E e4, E e5)  
      boolean addAll​(java.util.Collection<? extends E> c)
      Adds all of the elements in the specified collection to this set.
      boolean all​(long mask)  
      static boolean all​(long flags, long mask)  
      boolean all​(E e1)  
      boolean all​(E... rest)  
      boolean all​(E e1, E e2)  
      boolean all​(E e1, E e2, E e3)  
      boolean all​(E e1, E e2, E e3, E e4)  
      boolean all​(E e1, E e2, E e3, E e4, E e5)  
      long allBitsMask()  
      static <E extends java.lang.Enum<E>>
      BitFieldSet<E>
      allOf​(java.lang.Class<E> elementType)
      Creates an enum set containing all of the elements in the specified element type.
      boolean andNotMask​(long mask)  
      static long andNotMask​(long flags, long mask)  
      boolean any​(long mask)  
      static boolean any​(long flags, long mask)  
      boolean any​(E e1)  
      boolean any​(E... rest)  
      boolean any​(E e1, E e2)  
      boolean any​(E e1, E e2, E e3)  
      boolean any​(E e1, E e2, E e3, E e4)  
      boolean any​(E e1, E e2, E e3, E e4, E e5)  
      void clear()
      Removes all of the elements from this set.
      BitFieldSet<E> clone()
      Returns a copy of this set.
      void complement()  
      static <E extends java.lang.Enum<E>>
      BitFieldSet<E>
      complementOf​(BitFieldSet<E> s)
      Creates an enum set with the same element type as the specified enum set, initially containing all the elements of this type that are not contained in the specified set.
      boolean contains​(java.lang.Object e)
      Returns true if this set contains the specified element.
      boolean containsAll​(java.util.Collection<?> c)
      Returns true if this set contains all of the elements in the specified collection.
      static <E extends java.lang.Enum<E>>
      BitFieldSet<E>
      copyOf​(BitFieldSet<E> s)
      Creates an enum set with the same element type as the specified enum set, initially containing the same elements (if any).
      static <E extends java.lang.Enum<E>>
      BitFieldSet<E>
      copyOf​(java.util.Collection<E> c)
      Creates an enum set initialized from the specified collection.
      boolean equals​(java.lang.Object o)
      Compares the specified object with this set for equality.
      long get​(E e1)
      Returns unsigned value for the field, except if the field is 64 bits
      static <E extends java.lang.Enum<E>>
      byte
      getBitField​(byte elements, E e1)  
      static <E extends java.lang.Enum<E>>
      int
      getBitField​(int elements, E e1)  
      static <E extends java.lang.Enum<E>>
      long
      getBitField​(long elements, E e1)
      Returns signed value for the field, except if the field is 64 bits
      static <E extends java.lang.Enum<E>>
      short
      getBitField​(short elements, E e1)  
      static <E extends java.lang.Enum<E>>
      long[]
      getBitMasks​(java.lang.Class<E> elementType)
      Returns all of the values comprising E.
      byte getByte​(E e1)  
      int getInt​(E e1)  
      long getLong​(E e1)
      Returns signed value for the field, except if the field is 64 bits
      short getShort​(E e1)  
      long getSigned​(E e1, int maxBits, java.lang.String typeName)  
      static int getTotalBits​(long[] bitMasks)  
      byte getUByte​(E e1)  
      int getUInt​(E e1)  
      static <E extends java.lang.Enum<E>>
      E[]
      getUniverse​(java.lang.Class<E> elementType)
      Returns all of the values comprising E.
      long getUnsigned​(E e1, int maxBits, java.lang.String typeName)  
      static <E extends java.lang.Enum<E>>
      long
      getUnsignedBitField​(long elements, E e1, int maxBits, java.lang.String typeName)
      Returns unsigned value for the field, except if the field is 64 bits
      short getUShort​(E e1)  
      static <E extends java.lang.Enum<E>>
      int
      intMask​(E e1)  
      boolean isEmpty()  
      java.util.Iterator<E> iterator()
      Returns an iterator over the elements contained in this set.
      static <E extends java.lang.Enum<E>>
      long
      longMask​(E e1)  
      long mask​(E e1)  
      long mask​(E... rest)  
      long mask​(E e1, E e2)  
      long mask​(E e1, E e2, E e3)  
      long mask​(E e1, E e2, E e3, E e4)  
      long mask​(E e1, E e2, E e3, E e4, E e5)  
      static long nextBitMask​(int nextAvailableBit, int bits)  
      boolean none​(long mask)  
      static boolean none​(long flags, long mask)  
      boolean none​(E e1)  
      boolean none​(E... rest)  
      boolean none​(E e1, E e2)  
      boolean none​(E e1, E e2, E e3)  
      boolean none​(E e1, E e2, E e3, E e4)  
      boolean none​(E e1, E e2, E e3, E e4, E e5)  
      static <E extends java.lang.Enum<E>>
      BitFieldSet<E>
      noneOf​(java.lang.Class<E> elementType)
      Creates an empty enum set with the specified element type.
      static <E extends java.lang.Enum<E>>
      BitFieldSet<E>
      of​(E e)
      Creates an enum set initially containing the specified element.
      static <E extends java.lang.Enum<E>>
      BitFieldSet<E>
      of​(E e1, E e2)
      Creates an enum set initially containing the specified elements.
      static <E extends java.lang.Enum<E>>
      BitFieldSet<E>
      of​(E first, E... rest)
      Creates an enum set initially containing the specified elements.
      static <E extends java.lang.Enum<E>>
      BitFieldSet<E>
      of​(E e1, E e2, E e3)
      Creates an enum set initially containing the specified elements.
      static <E extends java.lang.Enum<E>>
      BitFieldSet<E>
      of​(E e1, E e2, E e3, E e4)
      Creates an enum set initially containing the specified elements.
      static <E extends java.lang.Enum<E>>
      BitFieldSet<E>
      of​(E e1, E e2, E e3, E e4, E e5)
      Creates an enum set initially containing the specified elements.
      static <E extends java.lang.Enum<E>>
      BitFieldSet<E>
      of​(java.lang.Class<E> declaringClass, E[] rest)
      Creates an enum set initially containing the specified elements.
      static <T extends java.lang.Enum<T>>
      BitFieldSet<T>
      of​(java.lang.Class<T> enumClass, long mask)
      Create a bit enum set from a bit mask
      boolean orMask​(long mask)  
      static long orMask​(long flags, long mask)  
      static <E extends java.lang.Enum<E>>
      BitFieldSet<E>
      range​(E from, E to)
      Creates an enum set initially containing all of the elements in the range defined by the two specified endpoints.
      boolean remove​(E... rest)  
      boolean remove​(E e1, E e2)  
      boolean remove​(E e1, E e2, E e3)  
      boolean remove​(E e1, E e2, E e3, E e4)  
      boolean remove​(E e1, E e2, E e3, E e4, E e5)  
      boolean remove​(java.lang.Object e)
      Removes the specified element from this set if it is present.
      boolean removeAll​(java.util.Collection<?> c)
      Removes from this set all of its elements that are contained in the specified collection.
      boolean replaceAll​(long mask)
      Deprecated.
      boolean retainAll​(java.util.Collection<?> c)
      Retains only the elements in this set that are contained in the specified collection.
      boolean setAll​(long mask)  
      static <E extends java.lang.Enum<E>>
      byte
      setBitField​(byte elements, E e1, byte value)  
      static <E extends java.lang.Enum<E>>
      int
      setBitField​(int elements, E e1, int value)  
      static <E extends java.lang.Enum<E>>
      long
      setBitField​(long elements, E e1, int value)  
      static <E extends java.lang.Enum<E>>
      short
      setBitField​(short elements, E e1, short value)  
      void setBitField​(E e1, byte value)  
      void setBitField​(E e1, int value)  
      void setBitField​(E e1, long value)  
      void setBitField​(E e1, short value)  
      boolean setSigned​(E e1, long value)
      Set a signed value for the field
      boolean setUnsigned​(E e1, long value)
      Set a signed value for the field
      void setUnsignedField​(E e1, byte value)  
      void setUnsignedField​(E e1, int value)  
      void setUnsignedField​(E e1, long value)  
      void setUnsignedField​(E e1, short value)  
      int size()
      Returns the number of elements in this set.
      byte toByte()  
      int toInt()  
      long toLong()  
      short toShort()  
      java.lang.String toString()  
      • Methods inherited from class java.util.AbstractSet

        hashCode
      • Methods inherited from class java.util.AbstractCollection

        toArray, toArray
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Set

        spliterator, toArray, toArray
    • Method Detail

      • nextBitMask

        public static long nextBitMask​(int nextAvailableBit,
                                       int bits)
      • getUniverse

        public static <E extends java.lang.Enum<E>> E[] getUniverse​(java.lang.Class<E> elementType)
        Returns all of the values comprising E. The result is cloned and slower than SharedSecrets use but works in Java 11 and Java 8 because SharedSecrets are not shared publicly
        Type Parameters:
        E - type of enum
        Parameters:
        elementType - class of enum
        Returns:
        array of enum values
      • getBitMasks

        public static <E extends java.lang.Enum<E>> long[] getBitMasks​(java.lang.Class<E> elementType)
        Returns all of the values comprising E. The result is cloned and slower than SharedSecrets use but works in Java 11 and Java 8 because SharedSecrets are not shared publicly
        Type Parameters:
        E - type of enum
        Parameters:
        elementType - class of enum
        Returns:
        array of bit masks for enum values
      • getTotalBits

        public static int getTotalBits​(long[] bitMasks)
      • complement

        public void complement()
      • toLong

        public long toLong()
      • toInt

        public int toInt()
      • toShort

        public short toShort()
      • toByte

        public byte toByte()
      • allBitsMask

        public long allBitsMask()
      • orMask

        public boolean orMask​(long mask)
      • replaceAll

        @Deprecated
        public boolean replaceAll​(long mask)
        Deprecated.
        Set all bit fields to values in mask
        Parameters:
        mask - bit fields values
        Returns:
        true if any field values were modified
      • setAll

        public boolean setAll​(long mask)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.util.AbstractCollection<E extends java.lang.Enum<E>>
      • andNotMask

        public boolean andNotMask​(long mask)
      • any

        public boolean any​(long mask)
      • none

        public boolean none​(long mask)
      • all

        public boolean all​(long mask)
      • longMask

        public static <E extends java.lang.Enum<E>> long longMask​(E e1)
      • intMask

        public static <E extends java.lang.Enum<E>> int intMask​(E e1)
      • get

        public long get​(E e1)
        Returns unsigned value for the field, except if the field is 64 bits
        Parameters:
        e1 - field to get
        Returns:
        unsigned value
      • setUnsigned

        public boolean setUnsigned​(E e1,
                                   long value)
        Set a signed value for the field
        Parameters:
        e1 - field
        value - value to set
        Returns:
        true if elements changed by operation
      • setSigned

        public boolean setSigned​(E e1,
                                 long value)
        Set a signed value for the field
        Parameters:
        e1 - field
        value - value to set
        Returns:
        true if elements changed by operation
      • setBitField

        public void setBitField​(E e1,
                                long value)
      • setBitField

        public void setBitField​(E e1,
                                int value)
      • setBitField

        public void setBitField​(E e1,
                                short value)
      • setBitField

        public void setBitField​(E e1,
                                byte value)
      • setUnsignedField

        public void setUnsignedField​(E e1,
                                     long value)
      • setUnsignedField

        public void setUnsignedField​(E e1,
                                     int value)
      • setUnsignedField

        public void setUnsignedField​(E e1,
                                     short value)
      • setUnsignedField

        public void setUnsignedField​(E e1,
                                     byte value)
      • getUnsigned

        public long getUnsigned​(E e1,
                                int maxBits,
                                java.lang.String typeName)
      • getSigned

        public long getSigned​(E e1,
                              int maxBits,
                              java.lang.String typeName)
      • getLong

        public long getLong​(E e1)
        Returns signed value for the field, except if the field is 64 bits
        Parameters:
        e1 - field to get
        Returns:
        unsigned value
      • getInt

        public int getInt​(E e1)
      • getShort

        public short getShort​(E e1)
      • getByte

        public byte getByte​(E e1)
      • getUInt

        public int getUInt​(E e1)
      • getUShort

        public short getUShort​(E e1)
      • getUByte

        public byte getUByte​(E e1)
      • orMask

        public static long orMask​(long flags,
                                  long mask)
      • andNotMask

        public static long andNotMask​(long flags,
                                      long mask)
      • any

        public static boolean any​(long flags,
                                  long mask)
      • all

        public static boolean all​(long flags,
                                  long mask)
      • none

        public static boolean none​(long flags,
                                   long mask)
      • mask

        public long mask​(E e1)
      • mask

        public long mask​(E e1,
                         E e2)
      • mask

        public long mask​(E e1,
                         E e2,
                         E e3)
      • mask

        public long mask​(E e1,
                         E e2,
                         E e3,
                         E e4)
      • mask

        public long mask​(E e1,
                         E e2,
                         E e3,
                         E e4,
                         E e5)
      • mask

        @SafeVarargs
        public final long mask​(E... rest)
      • add

        public boolean add​(E e1,
                           E e2)
      • add

        public boolean add​(E e1,
                           E e2,
                           E e3)
      • add

        public boolean add​(E e1,
                           E e2,
                           E e3,
                           E e4)
      • add

        public boolean add​(E e1,
                           E e2,
                           E e3,
                           E e4,
                           E e5)
      • add

        @SafeVarargs
        public final boolean add​(E... rest)
      • remove

        public boolean remove​(E e1,
                              E e2)
      • remove

        public boolean remove​(E e1,
                              E e2,
                              E e3)
      • remove

        public boolean remove​(E e1,
                              E e2,
                              E e3,
                              E e4)
      • remove

        public boolean remove​(E e1,
                              E e2,
                              E e3,
                              E e4,
                              E e5)
      • remove

        @SafeVarargs
        public final boolean remove​(E... rest)
      • any

        public boolean any​(E e1)
      • any

        public boolean any​(E e1,
                           E e2)
      • any

        public boolean any​(E e1,
                           E e2,
                           E e3)
      • any

        public boolean any​(E e1,
                           E e2,
                           E e3,
                           E e4)
      • any

        public boolean any​(E e1,
                           E e2,
                           E e3,
                           E e4,
                           E e5)
      • any

        @SafeVarargs
        public final boolean any​(E... rest)
      • all

        public boolean all​(E e1)
      • all

        public boolean all​(E e1,
                           E e2)
      • all

        public boolean all​(E e1,
                           E e2,
                           E e3)
      • all

        public boolean all​(E e1,
                           E e2,
                           E e3,
                           E e4)
      • all

        public boolean all​(E e1,
                           E e2,
                           E e3,
                           E e4,
                           E e5)
      • all

        @SafeVarargs
        public final boolean all​(E... rest)
      • none

        public boolean none​(E e1)
      • none

        public boolean none​(E e1,
                            E e2)
      • none

        public boolean none​(E e1,
                            E e2,
                            E e3)
      • none

        public boolean none​(E e1,
                            E e2,
                            E e3,
                            E e4)
      • none

        public boolean none​(E e1,
                            E e2,
                            E e3,
                            E e4,
                            E e5)
      • none

        @SafeVarargs
        public final boolean none​(E... rest)
      • iterator

        @NotNull
        public java.util.Iterator<E> iterator()
        Returns an iterator over the elements contained in this set. The iterator traverses the elements in their natural order (which is the order in which the enum constants are declared). The returned Iterator is a "snapshot" iterator that will never throw ConcurrentModificationException; the elements are traversed as they existed when this call was invoked.

        NOTE: bit field iteration requires skipping fields whose bits are all 0 so constant time is violated

        Specified by:
        iterator in interface java.util.Collection<E extends java.lang.Enum<E>>
        Specified by:
        iterator in interface java.lang.Iterable<E extends java.lang.Enum<E>>
        Specified by:
        iterator in interface java.util.Set<E extends java.lang.Enum<E>>
        Specified by:
        iterator in class java.util.AbstractCollection<E extends java.lang.Enum<E>>
        Returns:
        an iterator over the elements contained in this set
      • size

        public int size()
        Returns the number of elements in this set.
        Specified by:
        size in interface java.util.Collection<E extends java.lang.Enum<E>>
        Specified by:
        size in interface java.util.Set<E extends java.lang.Enum<E>>
        Specified by:
        size in class java.util.AbstractCollection<E extends java.lang.Enum<E>>
        Returns:
        the number of elements in this set
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<E extends java.lang.Enum<E>>
        Specified by:
        isEmpty in interface java.util.Set<E extends java.lang.Enum<E>>
        Overrides:
        isEmpty in class java.util.AbstractCollection<E extends java.lang.Enum<E>>
        Returns:
        true if this set contains no elements
      • contains

        public boolean contains​(java.lang.Object e)
        Returns true if this set contains the specified element.
        Specified by:
        contains in interface java.util.Collection<E extends java.lang.Enum<E>>
        Specified by:
        contains in interface java.util.Set<E extends java.lang.Enum<E>>
        Overrides:
        contains in class java.util.AbstractCollection<E extends java.lang.Enum<E>>
        Parameters:
        e - element to be checked for containment in this collection
        Returns:
        true if this set contains the specified element
      • add

        public boolean add​(E e)
        Adds the specified element to this set if it is not already present.
        Specified by:
        add in interface java.util.Collection<E extends java.lang.Enum<E>>
        Specified by:
        add in interface java.util.Set<E extends java.lang.Enum<E>>
        Overrides:
        add in class java.util.AbstractCollection<E extends java.lang.Enum<E>>
        Parameters:
        e - element to be added to this set
        Returns:
        true if the set changed as a result of the call
        Throws:
        java.lang.NullPointerException - if e is null
      • remove

        public boolean remove​(java.lang.Object e)
        Removes the specified element from this set if it is present.
        Specified by:
        remove in interface java.util.Collection<E extends java.lang.Enum<E>>
        Specified by:
        remove in interface java.util.Set<E extends java.lang.Enum<E>>
        Overrides:
        remove in class java.util.AbstractCollection<E extends java.lang.Enum<E>>
        Parameters:
        e - element to be removed from this set, if present
        Returns:
        true if the set contained the specified element
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Returns true if this set contains all of the elements in the specified collection.
        Specified by:
        containsAll in interface java.util.Collection<E extends java.lang.Enum<E>>
        Specified by:
        containsAll in interface java.util.Set<E extends java.lang.Enum<E>>
        Overrides:
        containsAll in class java.util.AbstractCollection<E extends java.lang.Enum<E>>
        Parameters:
        c - collection to be checked for containment in this set
        Returns:
        true if this set contains all of the elements in the specified collection
        Throws:
        java.lang.NullPointerException - if the specified collection is null
      • addAll

        public boolean addAll​(java.util.Collection<? extends E> c)
        Adds all of the elements in the specified collection to this set.
        Specified by:
        addAll in interface java.util.Collection<E extends java.lang.Enum<E>>
        Specified by:
        addAll in interface java.util.Set<E extends java.lang.Enum<E>>
        Overrides:
        addAll in class java.util.AbstractCollection<E extends java.lang.Enum<E>>
        Parameters:
        c - collection whose elements are to be added to this set
        Returns:
        true if this set changed as a result of the call
        Throws:
        java.lang.NullPointerException - if the specified collection or any of its elements are null
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Removes from this set all of its elements that are contained in the specified collection.
        Specified by:
        removeAll in interface java.util.Collection<E extends java.lang.Enum<E>>
        Specified by:
        removeAll in interface java.util.Set<E extends java.lang.Enum<E>>
        Overrides:
        removeAll in class java.util.AbstractSet<E extends java.lang.Enum<E>>
        Parameters:
        c - elements to be removed from this set
        Returns:
        true if this set changed as a result of the call
        Throws:
        java.lang.NullPointerException - if the specified collection is null
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Retains only the elements in this set that are contained in the specified collection.
        Specified by:
        retainAll in interface java.util.Collection<E extends java.lang.Enum<E>>
        Specified by:
        retainAll in interface java.util.Set<E extends java.lang.Enum<E>>
        Overrides:
        retainAll in class java.util.AbstractCollection<E extends java.lang.Enum<E>>
        Parameters:
        c - elements to be retained in this set
        Returns:
        true if this set changed as a result of the call
        Throws:
        java.lang.NullPointerException - if the specified collection is null
      • clear

        public void clear()
        Removes all of the elements from this set.
        Specified by:
        clear in interface java.util.Collection<E extends java.lang.Enum<E>>
        Specified by:
        clear in interface java.util.Set<E extends java.lang.Enum<E>>
        Overrides:
        clear in class java.util.AbstractCollection<E extends java.lang.Enum<E>>
      • of

        public static <T extends java.lang.Enum<T>> BitFieldSet<T> of​(@NotNull
                                                                      java.lang.Class<T> enumClass,
                                                                      long mask)
        Create a bit enum set from a bit mask
        Type Parameters:
        T - enum type
        Parameters:
        enumClass - class of the enum
        mask - bit mask for items
        Returns:
        bit enum set
      • clone

        public BitFieldSet<E> clone()
        Returns a copy of this set.
        Overrides:
        clone in class java.lang.Object
        Returns:
        a copy of this set
      • equals

        public boolean equals​(java.lang.Object o)
        Compares the specified object with this set for equality. Returns true if the given object is also a set, the two sets have the same size, and every member of the given set is contained in this set.
        Specified by:
        equals in interface java.util.Collection<E extends java.lang.Enum<E>>
        Specified by:
        equals in interface java.util.Set<E extends java.lang.Enum<E>>
        Overrides:
        equals in class java.util.AbstractSet<E extends java.lang.Enum<E>>
        Parameters:
        o - object to be compared for equality with this set
        Returns:
        true if the specified object is equal to this set
      • noneOf

        public static <E extends java.lang.Enum<E>> BitFieldSet<E> noneOf​(java.lang.Class<E> elementType)
        Creates an empty enum set with the specified element type.
        Type Parameters:
        E - The class of the elements in the set
        Parameters:
        elementType - the class object of the element type for this enum set
        Returns:
        An empty enum set of the specified type.
        Throws:
        java.lang.NullPointerException - if elementType is null
      • setBitField

        public static <E extends java.lang.Enum<E>> long setBitField​(long elements,
                                                                     E e1,
                                                                     int value)
      • setBitField

        public static <E extends java.lang.Enum<E>> int setBitField​(int elements,
                                                                    E e1,
                                                                    int value)
      • setBitField

        public static <E extends java.lang.Enum<E>> short setBitField​(short elements,
                                                                      E e1,
                                                                      short value)
      • setBitField

        public static <E extends java.lang.Enum<E>> byte setBitField​(byte elements,
                                                                     E e1,
                                                                     byte value)
      • getUnsignedBitField

        public static <E extends java.lang.Enum<E>> long getUnsignedBitField​(long elements,
                                                                             E e1,
                                                                             int maxBits,
                                                                             java.lang.String typeName)
        Returns unsigned value for the field, except if the field is 64 bits
        Type Parameters:
        E - type of enum
        Parameters:
        elements - bit mask for elements
        e1 - field to get
        maxBits - maximum bits for type
        typeName - name of type
        Returns:
        unsigned value
      • getBitField

        public static <E extends java.lang.Enum<E>> long getBitField​(long elements,
                                                                     E e1)
        Returns signed value for the field, except if the field is 64 bits
        Type Parameters:
        E - type of enum
        Parameters:
        elements - bit mask for elements
        e1 - field to get
        Returns:
        unsigned value
      • getBitField

        public static <E extends java.lang.Enum<E>> int getBitField​(int elements,
                                                                    E e1)
      • getBitField

        public static <E extends java.lang.Enum<E>> short getBitField​(short elements,
                                                                      E e1)
      • getBitField

        public static <E extends java.lang.Enum<E>> byte getBitField​(byte elements,
                                                                     E e1)
      • allOf

        public static <E extends java.lang.Enum<E>> BitFieldSet<E> allOf​(java.lang.Class<E> elementType)
        Creates an enum set containing all of the elements in the specified element type.
        Type Parameters:
        E - The class of the elements in the set
        Parameters:
        elementType - the class object of the element type for this enum set
        Returns:
        An enum set containing all the elements in the specified type.
        Throws:
        java.lang.NullPointerException - if elementType is null
      • copyOf

        public static <E extends java.lang.Enum<E>> BitFieldSet<E> copyOf​(BitFieldSet<E> s)
        Creates an enum set with the same element type as the specified enum set, initially containing the same elements (if any).
        Type Parameters:
        E - The class of the elements in the set
        Parameters:
        s - the enum set from which to initialize this enum set
        Returns:
        A copy of the specified enum set.
        Throws:
        java.lang.NullPointerException - if s is null
      • copyOf

        public static <E extends java.lang.Enum<E>> BitFieldSet<E> copyOf​(java.util.Collection<E> c)
        Creates an enum set initialized from the specified collection. If the specified collection is an BitFieldSet instance, this static factory method behaves identically to copyOf(BitFieldSet). Otherwise, the specified collection must contain at least one element (in order to determine the new enum set's element type).
        Type Parameters:
        E - The class of the elements in the collection
        Parameters:
        c - the collection from which to initialize this enum set
        Returns:
        An enum set initialized from the given collection.
        Throws:
        java.lang.IllegalArgumentException - if c is not an BitFieldSet instance and contains no elements
        java.lang.NullPointerException - if c is null
      • complementOf

        public static <E extends java.lang.Enum<E>> BitFieldSet<E> complementOf​(BitFieldSet<E> s)
        Creates an enum set with the same element type as the specified enum set, initially containing all the elements of this type that are not contained in the specified set.
        Type Parameters:
        E - The class of the elements in the enum set
        Parameters:
        s - the enum set from whose complement to initialize this enum set
        Returns:
        The complement of the specified set in this set
        Throws:
        java.lang.NullPointerException - if s is null
      • of

        public static <E extends java.lang.Enum<E>> BitFieldSet<E> of​(E e)
        Creates an enum set initially containing the specified element.

        Overloads of this method exist to initialize an enum set with one through five elements. A sixth overloading is provided that uses the varargs feature. This overloading may be used to create an enum set initially containing an arbitrary number of elements, but is likely to run slower than the overloads that do not use varargs.

        Type Parameters:
        E - The class of the specified element and of the set
        Parameters:
        e - the element that this set is to contain initially
        Returns:
        an enum set initially containing the specified element
        Throws:
        java.lang.NullPointerException - if e is null
      • of

        public static <E extends java.lang.Enum<E>> BitFieldSet<E> of​(E e1,
                                                                      E e2)
        Creates an enum set initially containing the specified elements.

        Overloads of this method exist to initialize an enum set with one through five elements. A sixth overloading is provided that uses the varargs feature. This overloading may be used to create an enum set initially containing an arbitrary number of elements, but is likely to run slower than the overloads that do not use varargs.

        Type Parameters:
        E - The class of the parameter elements and of the set
        Parameters:
        e1 - an element that this set is to contain initially
        e2 - another element that this set is to contain initially
        Returns:
        an enum set initially containing the specified elements
        Throws:
        java.lang.NullPointerException - if any parameters are null
      • of

        public static <E extends java.lang.Enum<E>> BitFieldSet<E> of​(E e1,
                                                                      E e2,
                                                                      E e3)
        Creates an enum set initially containing the specified elements.

        Overloads of this method exist to initialize an enum set with one through five elements. A sixth overloading is provided that uses the varargs feature. This overloading may be used to create an enum set initially containing an arbitrary number of elements, but is likely to run slower than the overloads that do not use varargs.

        Type Parameters:
        E - The class of the parameter elements and of the set
        Parameters:
        e1 - an element that this set is to contain initially
        e2 - another element that this set is to contain initially
        e3 - another element that this set is to contain initially
        Returns:
        an enum set initially containing the specified elements
        Throws:
        java.lang.NullPointerException - if any parameters are null
      • of

        public static <E extends java.lang.Enum<E>> BitFieldSet<E> of​(E e1,
                                                                      E e2,
                                                                      E e3,
                                                                      E e4)
        Creates an enum set initially containing the specified elements.

        Overloads of this method exist to initialize an enum set with one through five elements. A sixth overloading is provided that uses the varargs feature. This overloading may be used to create an enum set initially containing an arbitrary number of elements, but is likely to run slower than the overloads that do not use varargs.

        Type Parameters:
        E - The class of the parameter elements and of the set
        Parameters:
        e1 - an element that this set is to contain initially
        e2 - another element that this set is to contain initially
        e3 - another element that this set is to contain initially
        e4 - another element that this set is to contain initially
        Returns:
        an enum set initially containing the specified elements
        Throws:
        java.lang.NullPointerException - if any parameters are null
      • of

        public static <E extends java.lang.Enum<E>> BitFieldSet<E> of​(E e1,
                                                                      E e2,
                                                                      E e3,
                                                                      E e4,
                                                                      E e5)
        Creates an enum set initially containing the specified elements.

        Overloads of this method exist to initialize an enum set with one through five elements. A sixth overloading is provided that uses the varargs feature. This overloading may be used to create an enum set initially containing an arbitrary number of elements, but is likely to run slower than the overloads that do not use varargs.

        Type Parameters:
        E - The class of the parameter elements and of the set
        Parameters:
        e1 - an element that this set is to contain initially
        e2 - another element that this set is to contain initially
        e3 - another element that this set is to contain initially
        e4 - another element that this set is to contain initially
        e5 - another element that this set is to contain initially
        Returns:
        an enum set initially containing the specified elements
        Throws:
        java.lang.NullPointerException - if any parameters are null
      • of

        @SafeVarargs
        public static <E extends java.lang.Enum<E>> BitFieldSet<E> of​(E first,
                                                                      E... rest)
        Creates an enum set initially containing the specified elements. This factory, whose parameter list uses the varargs feature, may be used to create an enum set initially containing an arbitrary number of elements, but it is likely to run slower than the overloads that do not use varargs.
        Type Parameters:
        E - The class of the parameter elements and of the set
        Parameters:
        first - an element that the set is to contain initially
        rest - the remaining elements the set is to contain initially
        Returns:
        an enum set initially containing the specified elements
        Throws:
        java.lang.NullPointerException - if any of the specified elements are null, or if rest is null
      • of

        public static <E extends java.lang.Enum<E>> BitFieldSet<E> of​(@NotNull
                                                                      java.lang.Class<E> declaringClass,
                                                                      E[] rest)
        Creates an enum set initially containing the specified elements. This factory, whose parameter list uses the varargs feature, may be used to create an enum set initially containing an arbitrary number of elements, but it is likely to run slower than the overloads that do not use varargs.
        Type Parameters:
        E - The class of the parameter elements and of the set
        Parameters:
        declaringClass - declaring class of enum
        rest - the remaining elements the set is to contain initially
        Returns:
        an enum set initially containing the specified elements
        Throws:
        java.lang.NullPointerException - if any of the specified elements are null, or if rest is null
      • range

        public static <E extends java.lang.Enum<E>> BitFieldSet<E> range​(E from,
                                                                         E to)
        Creates an enum set initially containing all of the elements in the range defined by the two specified endpoints. The returned set will contain the endpoints themselves, which may be identical but must not be out of order.
        Type Parameters:
        E - The class of the parameter elements and of the set
        Parameters:
        from - the first element in the range
        to - the last element in the range
        Returns:
        an enum set initially containing all of the elements in the range defined by the two specified endpoints
        Throws:
        java.lang.NullPointerException - if from or to are null
        java.lang.IllegalArgumentException - if from.compareTo(to) > 0