Package cdc.enums
Class AbstractMask<M extends AbstractMask<M,V>,V>
java.lang.Object
cdc.enums.AbstractMask<M,V>
- Type Parameters:
M- The mask type.V- The enum type.
- All Implemented Interfaces:
Mask<M,V>
- Direct Known Subclasses:
BooleanMask,EnumMask,NullableBooleanMask,NullableEnumMask
Mask (set) of values belonging to a list type.
Objects of this class are immutable.
A typical implementation should look like this:
public final class FooMask extends AbstractEnumMask<FooMask, Foo> {
public static final Support<FooMask, Foo> SUPPORT = support(FooMask.class, FooMask::new, FooType, Nullable.FALSE);
private FooMask(Support<FooMask, Foo> support,
Set<Foo> values) {
super(support, values);
}
}
For a standard enum, one can declare:
public final class FooMask extends AbstractEnumMask<FooMask, Foo> {
public static final Support<FooMask, Foo> SUPPORT = support(FooMask.class, FooMask::new, Foo.class, Nullable.FALSE);
private FooMask(Support<FooMask, Foo> support,
Set<Foo> values) {
super(support, values);
}
}
- Author:
- Damien Carbonne
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the intersection of this mask with another one.Returns a new mask reduced with a value.final booleanReturnstrueif all values of this mask are contained in another mask.final booleanempty()booleanfull()inthashCode()booleanReturnstrueif a value is not contained.booleanisEmpty()booleanisFull()booleanbooleanReturnstrueif a value is contained.not()Returns the complement of this mask (at the time of calling this method).Returns the union of this mask with another one.Returns a new mask augmented with a value.Sets or clears a value.setAll(boolean enabled) Returns an empty or full mask.protected static <M extends AbstractMask<M,V>, V>
MaskSupport<M,V> support(Class<M> maskClass, AbstractMask.Creator<M, V> creator, ListType<V> type, Nullable nullable) Creates a Support implementation.protected static <M extends AbstractMask<M,V>, V extends Enum<V>>
MaskSupport<M,V> support(Class<M> maskClass, AbstractMask.Creator<M, V> creator, Class<V> enumClass, Nullable nullable) Creates a Support implementation for a standard enum.toString()Returns a string representation of this mask.
-
Field Details
-
support
The associated support class. -
values
The mask values.
-
-
Constructor Details
-
AbstractMask
-
-
Method Details
-
support
protected static <M extends AbstractMask<M,V>, MaskSupport<M,V> V> support(Class<M> maskClass, AbstractMask.Creator<M, V> creator, ListType<V> type, Nullable nullable) Creates a Support implementation.- Type Parameters:
M- The mask type.V- The enum type.- Parameters:
maskClass- The mask class.creator- The mask factory.type- The type.nullable-Nullable.TRUEifnullis a valid value.- Returns:
- A Support implementation.
-
support
protected static <M extends AbstractMask<M,V>, MaskSupport<M,V extends Enum<V>> V> support(Class<M> maskClass, AbstractMask.Creator<M, V> creator, Class<V> enumClass, Nullable nullable) Creates a Support implementation for a standard enum.- Type Parameters:
M- The mask type.V- The enum type.- Parameters:
maskClass- The mask class.creator- The mask factory.enumClass- The enum class.nullable-Nullable.TRUEifnullis a valid value.- Returns:
- A Support implementation.
-
getSupport
- Specified by:
getSupportin interfaceMask<M extends AbstractMask<M,V>, V> - Returns:
- The enum type.
-
isNullable
public boolean isNullable()- Specified by:
isNullablein interfaceMask<M extends AbstractMask<M,V>, V> - Returns:
trueif this mask is a nullable mask.
-
isEmpty
public boolean isEmpty() -
isFull
public boolean isFull() -
getValues
-
isSet
Description copied from interface:MaskReturnstrueif a value is contained. -
isClear
Description copied from interface:MaskReturnstrueif a value is not contained. -
set
Description copied from interface:MaskSets or clears a value. -
set
Description copied from interface:MaskReturns a new mask augmented with a value.If
valueis already set, returns this mask. -
clear
Description copied from interface:MaskReturns a new mask reduced with a value.If
valueis already cleared, returns this mask. -
setAll
Description copied from interface:MaskReturns an empty or full mask.The full mask may change if underlying enum type is dynamic.
-
empty
-
full
-
and
Description copied from interface:MaskReturns the intersection of this mask with another one. -
and
-
and
-
or
Description copied from interface:MaskReturns the union of this mask with another one. -
or
-
or
-
not
Description copied from interface:MaskReturns the complement of this mask (at the time of calling this method). -
contains
Description copied from interface:MaskReturnstrueif all values of this mask are contained in another mask. -
contains
-
equals
-
hashCode
public int hashCode() -
toString
Description copied from interface:MaskReturns a string representation of this mask. -
toString
-