Top Description Inners Fields Constructors Methods
org.newsclub.net.unix

public abstract Class NamedIntegerBitmask<T extends NamedIntegerBitmask<T>>

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Annotations
@NonNullByDefault
Type Parameters
<T>
The subclass's type itself.
Imports
java.io.Serializable, java.lang.reflect.Array, java.util.ArrayList, .List, .Objects, org.eclipse.jdt.annotation.NonNull, .NonNullByDefault, .Nullable

Describes a 32-bit bitmask that supports named flags.
Author
Christian Kohlschütter

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static interface
NamedIntegerBitmask.Constructor<
This type.
T extends NamedIntegerBitmask<T>
>

Creates a new instance.

Field Summary

Modifier and TypeField and Description
private final int
flags

Flag value.

private final String
name

Name of the flag/flag set.

private static final long

Constructor Summary

AccessConstructor and Description
protected
NamedIntegerBitmask(@Nullable String
The name of the flag / flag set.
name
,
int
The flag value.
flags
)

Creates a new named flag.

Method Summary

Modifier and TypeMethod and Description
protected final T

Returns:

An instance combining both.
combineWith
(T[]
The array of all defined flags, expected "none".
allFlags
,
T
The "none" flag set.
flagsNone
,
NamedIntegerBitmask.Constructor<@NonNull T>
The constructor.
constr
,
T
The other flag / flag set to merge.
other
)

Combines two flags / flag sets (use this to implement combineWith(NamedIntegerBitmask)).

public abstract T

Returns:

An instance combining both.
combineWith
(T
The other flag / flag set.
other
)

Combines two flags / flag sets.

public final boolean

Returns:

true iff set.
hasFlag
(T
The flag to check.
flag
)

Checks if the given flag is set.

public final String

Returns:

The name.
name
()

Returns the name of the flag / flag set.

protected static final <
The subclass's type itself.
T extends NamedIntegerBitmask<T>
>
T

Returns:

An instance representing the flag value.
resolve
(T[]
The array of all defined flags, expected "none".
allFlags
,
T
The "none" flag set.
flagsNone
,
NamedIntegerBitmask.Constructor<T>
The constructor.
constr
,
int
The flag value.
v
)

Returns a NamedIntegerBitmask instance given a flag value.

protected static final <
The subclass's type itself.
T extends NamedIntegerBitmask<T>
>
T

Returns:

An instance representing the flag values.
resolve
(T[]
The array of all defined flags, expected "none".
allFlags
,
T
The "none" flag set.
flagsNone
,
NamedIntegerBitmask.Constructor<T>
The constructor.
constr
,
@NonNull T[]
The flags to set, potentially empty.
setFlags
)

Returns a NamedIntegerBitmask instance given a series of flags.

public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public final int

Returns:

The value.
value
()

Returns the value of the flag / flag set.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

flagsback to summary
private final int flags

Flag value.

nameback to summary
private final String name

Name of the flag/flag set.

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

NamedIntegerBitmaskback to summary
protected NamedIntegerBitmask(@Nullable String name, int flags)

Creates a new named flag.

Parameters
name:@Nullable String

The name of the flag / flag set.

flags:int

The flag value.

Method Detail

combineWithback to summary
protected final T combineWith(T[] allFlags, T flagsNone, NamedIntegerBitmask.Constructor<@NonNull T> constr, T other)

Combines two flags / flag sets (use this to implement combineWith(NamedIntegerBitmask)).

Parameters
allFlags:T[]

The array of all defined flags, expected "none".

flagsNone:T

The "none" flag set.

constr:NamedIntegerBitmask.Constructor<@NonNull T>

The constructor.

other:T

The other flag / flag set to merge.

Returns:T

An instance combining both.

Annotations
@SuppressWarnings:PMD.ShortMethodName, null
combineWithback to summary
public abstract T combineWith(T other)

Combines two flags / flag sets.

Parameters
other:T

The other flag / flag set.

Returns:T

An instance combining both.

Annotations
@SuppressWarnings:PMD.ShortMethodName
hasFlagback to summary
public final boolean hasFlag(T flag)

Checks if the given flag is set.

Parameters
flag:T

The flag to check.

Returns:boolean

true iff set.

nameback to summary
public final String name()

Returns the name of the flag / flag set.

Returns:String

The name.

resolveback to summary
protected static final <T extends NamedIntegerBitmask<T>> T resolve(T[] allFlags, T flagsNone, NamedIntegerBitmask.Constructor<T> constr, int v)

Returns a NamedIntegerBitmask instance given a flag value.

Parameters
<T>
The subclass's type itself.
allFlags:T[]

The array of all defined flags, expected "none".

flagsNone:T

The "none" flag set.

constr:NamedIntegerBitmask.Constructor<T>

The constructor.

v:int

The flag value.

Returns:T

An instance representing the flag value.

Annotations
@SuppressWarnings:null, unchecked
resolveback to summary
protected static final <T extends NamedIntegerBitmask<T>> T resolve(T[] allFlags, T flagsNone, NamedIntegerBitmask.Constructor<T> constr, @NonNull T[] setFlags)

Returns a NamedIntegerBitmask instance given a series of flags.

Parameters
<T>
The subclass's type itself.
allFlags:T[]

The array of all defined flags, expected "none".

flagsNone:T

The "none" flag set.

constr:NamedIntegerBitmask.Constructor<T>

The constructor.

setFlags:@NonNull T[]

The flags to set, potentially empty.

Returns:T

An instance representing the flag values.

toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
valueback to summary
public final int value()

Returns the value of the flag / flag set.

Returns:int

The value.

org.newsclub.net.unix back to summary

protected Interface NamedIntegerBitmask.Constructor<T extends NamedIntegerBitmask<T>>

Annotations
@FunctionalInterface
Type Parameters
<T>
This type.

Creates a new instance.

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

The instance.
newInstance
(@Nullable String
The name.
name
,
int
The flag value.
flags
)

Creates a new instance.

Method Detail

newInstanceback to summary
public T newInstance(@Nullable String name, int flags)

Creates a new instance.

Parameters
name:@Nullable String

The name.

flags:int

The flag value.

Returns:T

The instance.