Module org.newsclub.net.unix
Package org.newsclub.net.unix
Class NamedIntegerBitmask<T extends NamedIntegerBitmask<T>>
java.lang.Object
org.newsclub.net.unix.NamedIntegerBitmask<T>
- Type Parameters:
T- The subclass's type itself.
- All Implemented Interfaces:
Serializable
@NonNullByDefault
public abstract class NamedIntegerBitmask<T extends NamedIntegerBitmask<T>>
extends Object
implements Serializable
Describes a 32-bit bitmask that supports named flags.
- Author:
- Christian Kohlschütter
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceNamedIntegerBitmask.Constructor<T extends NamedIntegerBitmask<T>>Creates a new instance. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNamedIntegerBitmask(@Nullable String name, int flags) Creates a new named flag. -
Method Summary
Modifier and TypeMethodDescriptionabstract TcombineWith(T other) Combines two flags / flag sets.protected final TcombineWith(T[] allFlags, T flagsNone, NamedIntegerBitmask.Constructor<@NonNull T> constr, T other) Combines two flags / flag sets (use this to implementcombineWith(NamedIntegerBitmask)).final booleanChecks if the given flag is set.final Stringname()Returns the name of the flag / flag set.protected static final <T extends NamedIntegerBitmask<T>>
Tresolve(T[] allFlags, T flagsNone, NamedIntegerBitmask.Constructor<T> constr, int v) Returns aNamedIntegerBitmaskinstance given a flag value.protected static final <T extends NamedIntegerBitmask<T>>
Tresolve(T[] allFlags, T flagsNone, NamedIntegerBitmask.Constructor<T> constr, @NonNull T[] setFlags) Returns aNamedIntegerBitmaskinstance given a series of flags.final StringtoString()final intvalue()Returns the value of the flag / flag set.
-
Constructor Details
-
NamedIntegerBitmask
Creates a new named flag.- Parameters:
name- The name of the flag / flag set.flags- The flag value.
-
-
Method Details
-
name
-
value
public final int value()Returns the value of the flag / flag set.- Returns:
- The value.
-
hasFlag
Checks if the given flag is set.- Parameters:
flag- The flag to check.- Returns:
trueiff set.
-
toString
-
combineWith
protected final T combineWith(T[] allFlags, T flagsNone, NamedIntegerBitmask.Constructor<@NonNull T> constr, T other) Combines two flags / flag sets (use this to implementcombineWith(NamedIntegerBitmask)).- Parameters:
allFlags- The array of all defined flags, expected "none".flagsNone- The "none" flag set.constr- The constructor.other- The other flag / flag set to merge.- Returns:
- An instance combining both.
-
combineWith
-
resolve
protected static final <T extends NamedIntegerBitmask<T>> T resolve(T[] allFlags, T flagsNone, NamedIntegerBitmask.Constructor<T> constr, int v) Returns aNamedIntegerBitmaskinstance given a flag value.- Type Parameters:
T- The subclass's type itself.- Parameters:
allFlags- The array of all defined flags, expected "none".flagsNone- The "none" flag set.constr- The constructor.v- The flag value.- Returns:
- An instance representing the flag value.
-
resolve
protected static final <T extends NamedIntegerBitmask<T>> T resolve(T[] allFlags, T flagsNone, NamedIntegerBitmask.Constructor<T> constr, @NonNull T[] setFlags) Returns aNamedIntegerBitmaskinstance given a series of flags.- Type Parameters:
T- The subclass's type itself.- Parameters:
allFlags- The array of all defined flags, expected "none".flagsNone- The "none" flag set.constr- The constructor.setFlags- The flags to set, potentially empty.- Returns:
- An instance representing the flag values.
-