Package io.netty.util

Class ConstantPool<T extends Constant<T>>

java.lang.Object
io.netty.util.ConstantPool<T>
Type Parameters:
T - the type of the constant

public abstract class ConstantPool<T extends Constant<T>> extends Object
A pool of Constants.
  • Field Details

  • Constructor Details

    • ConstantPool

      public ConstantPool()
  • Method Details

    • valueOf

      public T valueOf(Class<?> firstNameComponent, String secondNameComponent)
    • valueOf

      public T valueOf(String name)
      Returns the Constant which is assigned to the specified name. If there's no such Constant, a new one will be created and returned. Once created, the subsequent calls with the same name will always return the previously created one (i.e. singleton.)
      Parameters:
      name - the name of the Constant
    • getOrCreate

      private T getOrCreate(String name)
      Get existing constant by name or creates new one if not exists. Threadsafe
      Parameters:
      name - the name of the Constant
    • exists

      public boolean exists(String name)
      Returns true if a AttributeKey exists for the given name.
    • newInstance

      public T newInstance(String name)
      Creates a new Constant for the given name or fail with an IllegalArgumentException if a Constant for the given name exists.
    • createOrThrow

      private T createOrThrow(String name)
      Creates constant by name or throws exception. Threadsafe
      Parameters:
      name - the name of the Constant
    • newConstant

      protected abstract T newConstant(int id, String name)
    • nextId

      @Deprecated public final int nextId()
      Deprecated.