Class ConstantSelector<T>

java.lang.Object
com.pixelmonmod.pixelmon.api.selector.type.ConstantSelector<T>
Type Parameters:
T - The type being selected
All Implemented Interfaces:
Selector<T>, Iterable<T>

public class ConstantSelector<T> extends Object implements Selector<T>
This represents an implementation of Selector where it will only ever give one value
  • Field Details

    • value

      protected final T value
  • Constructor Details

    • ConstantSelector

      protected ConstantSelector(T value)
  • Method Details

    • of

      public static <T> ConstantSelector<T> of(T value)
      Creates a new instance of the ConstantSelector with the given value
      Type Parameters:
      T - The type
      Parameters:
      value - The value to use
      Returns:
      The new instance
    • getRandom

      public T getRandom()
      Description copied from interface: Selector
      Gets a random element
      Specified by:
      getRandom in interface Selector<T>
      Returns:
      A random element
    • iterator

      @NotNull public @NotNull Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • codec

      public static <A> com.mojang.serialization.Codec<ConstantSelector<A>> codec(com.mojang.serialization.Codec<A> codec)
      Factory for creating an instanced version of this class
      Type Parameters:
      A - The type
      Parameters:
      codec - The type's codec
      Returns:
      The codec for the instanced selector
    • codec

      public <A> Function<com.mojang.serialization.Codec<A>,com.mojang.serialization.Codec<? extends Selector<A>>> codec()
      Description copied from interface: Selector
      Gets the codec for this selector
      Specified by:
      codec in interface Selector<T>
      Type Parameters:
      A - The type of the codec and selector
      Returns:
      The codec