Interface KeyedEnumTranslator<W>


@NullMarked @AsOf("2.0.0") @Internal public interface KeyedEnumTranslator<W>
  • Method Summary

    Modifier and Type
    Method
    Description
    static <W> KeyedEnumTranslator<W>
    byKey(Function<W,String> keyExtractor, W[] wrapperValues)
    Translator that maps wrapper to NMS by uppercasing a key extracted from the wrapper, and inverts by walking all wrapper constants and finding the one whose key matches (case-insensitively) the NMS enum's name.
    static <W extends Enum<W>>
    KeyedEnumTranslator<W>
    byName(Class<W> wrapperClass)
    Translator that uses the wrapper enum's own name() as the key.
    <N extends Enum<N>>
    W
    fromNms(N nmsEnum)
     
    <N extends Enum<N>>
    N
    toNms(W wrapped, Class<N> nmsEnumClass)
     
  • Method Details

    • toNms

      @AsOf("2.0.0") <N extends Enum<N>> N toNms(W wrapped, Class<N> nmsEnumClass)
    • fromNms

      @AsOf("2.1.0") <N extends Enum<N>> W fromNms(N nmsEnum)
    • byKey

      @AsOf("2.1.0") @Contract(value="_, _ -> new", pure=true) static <W> KeyedEnumTranslator<W> byKey(Function<W,String> keyExtractor, W[] wrapperValues)
      Translator that maps wrapper to NMS by uppercasing a key extracted from the wrapper, and inverts by walking all wrapper constants and finding the one whose key matches (case-insensitively) the NMS enum's name.
      Parameters:
      keyExtractor - extracts the key from a wrapper instance (typically lowercase)
      wrapperValues - all values of the wrapper enum (typically MyEnum.values())
      Since:
      2.0.0
    • byName

      @AsOf("2.1.0") @Contract(value="_ -> new", pure=true) static <W extends Enum<W>> KeyedEnumTranslator<W> byName(Class<W> wrapperClass)
      Translator that uses the wrapper enum's own name() as the key. Inverse lookup uses Enum.valueOf on the wrapper class.
      Parameters:
      wrapperClass - the wrapper enum class, used for inverse lookup
      Since:
      2.0.0