Class NamedInteger

java.lang.Object
org.newsclub.net.unix.NamedInteger
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AFSYSTEMSocketAddress.SysAddr, AFTIPCSocketAddress.AddressType, AFTIPCSocketAddress.Scope

@NonNullByDefault public class NamedInteger extends Object implements Serializable
A "named integer", usually used for constants. See the concrete implementations for usage.
Author:
Christian Kohlschütter
See Also:
  • Constructor Details

    • NamedInteger

      protected NamedInteger(int id)
      Creates a new NamedInteger instance, without actually naming it. A name of "UNDEFINED" is used.
      Parameters:
      id - The value.
    • NamedInteger

      protected NamedInteger(String name, int id)
      Creates a new NamedInteger instance.
      Parameters:
      name - The name.
      id - The value.
  • Method Details

    • name

      public final String name()
      Returns the name.
      Returns:
      The name.
    • value

      public final int value()
      Returns the value.
      Returns:
      The value.
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • init

      protected static final <T extends NamedInteger> T[] init(T[] values)
      Ensures that the VALUES array is configured correctly.
      Type Parameters:
      T - The instance type.
      Parameters:
      values - The VALUES 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 - The VALUES array.
      constr - The constructor for undefined values.
      v - The value.
      Returns:
      The instance.