Package cdc.enums
Interface Mask<M extends Mask<M,V>,V>
-
- Type Parameters:
M- The mask type.V- The value type.
- All Known Implementing Classes:
AbstractMask,BooleanMask,EnumMask,NullableBooleanMask,NullableEnumMask
public interface Mask<M extends Mask<M,V>,V>Interface describing a mask based on DagType.- Author:
- Damien Carbonne
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Mand(M other)Returns the intersection of this mask with another one.Mand(V value)Mand(V... values)Mclear(V value)Returns a new mask reduced with a value.booleancontains(M other)Returnstrueif all values of this mask are contained in another mask.booleancontains(V... values)Mempty()Mfull()MaskSupport<M,V>getSupport()Set<V>getValues()booleanisClear(V value)Returnstrueif a value is not contained.booleanisEmpty()booleanisFull()booleanisNullable()booleanisSet(V value)Returnstrueif a value is contained.Mnot()Returns the complement of this mask (at the time of calling this method).Mor(M other)Returns the union of this mask with another one.Mor(V value)Mor(V... values)Mset(V value)Returns a new mask augmented with a value.Mset(V value, boolean enabled)Sets or clears a value.MsetAll(boolean enabled)Returns an empty or full mask.StringtoString(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:
trueif this mask is a nullable mask.
-
isEmpty
boolean isEmpty()
- Returns:
trueif this mask is empty.
-
isFull
boolean isFull()
- Returns:
trueif this mask is full. The result may change if underlying enum type is dynamic.
-
isSet
boolean isSet(V value)
Returnstrueif a value is contained.- Parameters:
value- The value.- Returns:
trueifvalueis contained in this mask.
-
isClear
boolean isClear(V value)
Returnstrueif a value is not contained.- Parameters:
value- The value.- Returns:
trueifvalueis not contained in this mask.
-
set
M set(V value, boolean enabled)
Sets or clears a value.- Parameters:
value- The value.enabled- Iftruesets the value, otherwise clears it.- Returns:
- A new mask with
valueset or cleared.
-
set
M set(V value)
Returns a new mask augmented with a value.If
valueis 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
valueis 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- Iftrue, 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.
-
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.
-
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)
Returnstrueif all values of this mask are contained in another mask.- Parameters:
other- The other mask.- Returns:
trueif all values of this mask are contained inother.
-
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 (includingnull) to string.separator- The separator to use between values.- Returns:
- A string representation of this mask.
-
-