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
Nested ClassesModifier and TypeClassDescriptionstatic interfaceMarks a subclass that provides a method"public static T ofValue(int v)"that allows casting an integer to this type via reflection.protected static interfaceConstructor for "undefined" values. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNamedInteger(int id) Creates a newNamedIntegerinstance, without actually naming it.protectedNamedInteger(String name, int id) Creates a newNamedIntegerinstance. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanfinal inthashCode()protected static final <T extends NamedInteger>
T[]init(T[] values) Ensures that theVALUESarray is configured correctly.final Stringname()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 StringtoString()final intvalue()Returns the value.
-
Constructor Details
-
NamedInteger
protected NamedInteger(int id) Creates a newNamedIntegerinstance, without actually naming it. A name of "UNDEFINED" is used.- Parameters:
id- The value.
-
NamedInteger
Creates a newNamedIntegerinstance.- 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 theVALUESarray is configured correctly.- Type Parameters:
T- The instance type.- Parameters:
values- TheVALUESarray.- Returns:
- The verified
VALUESarray.
-
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- TheVALUESarray.constr- The constructor for undefined values.v- The value.- Returns:
- The instance.
-