Package cdc.enums

Interface Mask<M extends Mask<M,​V>,​V>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      M and​(M other)
      Returns the intersection of this mask with another one.
      M and​(V value)  
      M and​(V... values)  
      M clear​(V value)
      Returns a new mask reduced with a value.
      boolean contains​(M other)
      Returns true if all values of this mask are contained in another mask.
      boolean contains​(V... values)  
      M empty()  
      M full()  
      MaskSupport<M,​V> getSupport()  
      Set<V> getValues()  
      boolean isClear​(V value)
      Returns true if a value is not contained.
      boolean isEmpty()  
      boolean isFull()  
      boolean isNullable()  
      boolean isSet​(V value)
      Returns true if a value is contained.
      M not()
      Returns the complement of this mask (at the time of calling this method).
      M or​(M other)
      Returns the union of this mask with another one.
      M or​(V value)  
      M or​(V... values)  
      M set​(V value)
      Returns a new mask augmented with a value.
      M set​(V value, boolean enabled)
      Sets or clears a value.
      M setAll​(boolean enabled)
      Returns an empty or full mask.
      String toString​(Function<? super V,​String> valueToString, String separator)
      Returns a string representation of this mask.
    • Method Detail

      • getSupport

        MaskSupport<M,​V> getSupport()
        Returns:
        The enum type.
      • isNullable

        boolean isNullable()
        Returns:
        true if this mask is a nullable mask.
      • isEmpty

        boolean isEmpty()
        Returns:
        true if this mask is empty.
      • isFull

        boolean isFull()
        Returns:
        true if this mask is full. The result may change if underlying enum type is dynamic.
      • getValues

        Set<V> getValues()
        Returns:
        The values that are set.
      • isSet

        boolean isSet​(V value)
        Returns true if a value is contained.
        Parameters:
        value - The value.
        Returns:
        true if value is contained in this mask.
      • isClear

        boolean isClear​(V value)
        Returns true if a value is not contained.
        Parameters:
        value - The value.
        Returns:
        true if value is not contained in this mask.
      • set

        M set​(V value,
              boolean enabled)
        Sets or clears a value.
        Parameters:
        value - The value.
        enabled - If true sets the value, otherwise clears it.
        Returns:
        A new mask with value set or cleared.
      • set

        M set​(V value)
        Returns a new mask augmented with a value.

        If value is already set, returns this mask.

        Parameters:
        value - The value.
        Returns:
        A new mask augmented with value.
      • clear

        M clear​(V value)
        Returns a new mask reduced with a value.

        If value is already cleared, returns this mask.

        Parameters:
        value - The value.
        Returns:
        A new mask reduced with value.
      • setAll

        M setAll​(boolean enabled)
        Returns an empty or full mask.

        The full mask may change if underlying enum type is dynamic.

        Parameters:
        enabled - If true, creates a full mask. An empty mask otherwise.
        Returns:
        An empty or full mask.
      • empty

        M empty()
        Returns:
        An empty mask.
      • full

        M full()
        Returns:
        A full mask at the time of call. Result may change if underlying enum type is dynamic.
      • and

        M and​(M other)
        Returns the intersection of this mask with another one.
        Parameters:
        other - The other mask.
        Returns:
        The intersection of this mask with other.
      • and

        M and​(V value)
      • and

        M and​(V... values)
      • or

        M or​(M other)
        Returns the union of this mask with another one.
        Parameters:
        other - The other mask.
        Returns:
        The union of this mask with other.
      • or

        M or​(V value)
      • or

        M or​(V... values)
      • not

        M not()
        Returns the complement of this mask (at the time of calling this method).
        Returns:
        The complement of this mask (at the time of calling this method).
      • contains

        boolean contains​(M other)
        Returns true if all values of this mask are contained in another mask.
        Parameters:
        other - The other mask.
        Returns:
        true if all values of this mask are contained in other.
      • contains

        boolean contains​(V... values)
      • toString

        String toString​(Function<? super V,​String> valueToString,
                        String separator)
        Returns a string representation of this mask.
        Parameters:
        valueToString - The function used to converter values (including null) to string.
        separator - The separator to use between values.
        Returns:
        A string representation of this mask.