Class StringMapping<T>

java.lang.Object
org.wildfly.security.util.StringMapping<T>

public final class StringMapping<T> extends Object
An efficient mapping of enumerated strings to some other object.
Author:
David M. Lloyd
  • Constructor Details

    • StringMapping

      public StringMapping(StringEnumeration stringEnumeration, Function<String,T> mapping)
      Construct a new instance.
      Parameters:
      stringEnumeration - the string enumeration (must not be null)
      mapping - the mapping function (must not be null)
  • Method Details

    • getItemById

      public T getItemById(int index) throws IllegalArgumentException
      Get an item from this mapping by ID.
      Parameters:
      index - the index to look up
      Returns:
      the mapped item for the given ID
      Throws:
      IllegalArgumentException - if the given index is out of range
    • getItemByString

      public T getItemByString(String str) throws IllegalArgumentException
      Get an item from this mapping by the corresponding string name.
      Parameters:
      str - the string name
      Returns:
      the item
      Throws:
      IllegalArgumentException - if the string name is unknown
    • getStringEnumeration

      public StringEnumeration getStringEnumeration()
      Get the string enumeration for this mapping.
      Returns:
      the string enumeration for this mapping (not null)