java.lang.Object
org.newsclub.net.unix.NamedInteger
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AFSYSTEMSocketAddress.SysAddr
,AFTIPCErrInfo.ErrorCode
,AFTIPCSocketAddress.AddressType
,AFTIPCSocketAddress.Scope
,AFTIPCSocketOptions.MessageImportance
,AFTIPCTopologyEvent.Type
A "named integer", usually used for constants.
See the concrete implementations for usage.
- Author:
- Christian Kohlschütter
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Marks a subclass that provides a method"public static T ofValue(int v)"
that allows casting an integer to this type via reflection.protected static interface
Constructor for "undefined" values. -
Constructor Summary
ModifierConstructorDescriptionprotected
NamedInteger
(int id) Creates a newNamedInteger
instance, without actually naming it.protected
NamedInteger
(String name, int id) Creates a newNamedInteger
instance. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
final int
hashCode()
protected static final <T extends NamedInteger>
T[]init
(T[] values) Ensures that theVALUES
array is configured correctly.final String
name()
Returns the name.protected static final <T extends NamedInteger>
TofValue
(T[] values, NamedInteger.UndefinedValueConstructor<T> constr, int v) Returns an instance given an integer value.final String
toString()
final int
value()
Returns the value.
-
Constructor Details
-
NamedInteger
protected NamedInteger(int id) Creates a newNamedInteger
instance, without actually naming it. A name of "UNDEFINED" is used.- Parameters:
id
- The value.
-
NamedInteger
Creates a newNamedInteger
instance.- Parameters:
name
- The name.id
- The value.
-
-
Method Details
-
name
-
value
public final int value()Returns the value.- Returns:
- The value.
-
toString
-
hashCode
-
equals
-
init
Ensures that theVALUES
array is configured correctly.- Type Parameters:
T
- The instance type.- Parameters:
values
- TheVALUES
array.- Returns:
- The verified
VALUES
array.
-
ofValue
protected static final <T extends NamedInteger> T ofValue(T[] values, NamedInteger.UndefinedValueConstructor<T> constr, int v) Returns an instance given an integer value.- Type Parameters:
T
- The instance type.- Parameters:
values
- TheVALUES
array.constr
- The constructor for undefined values.v
- The value.- Returns:
- The instance.
-