Record Class HudObjectType<T extends HudObject>

java.lang.Object
java.lang.Record
kr.toxicity.hud.api.configuration.HudObjectType<T>
Type Parameters:
T - object type
Record Components:
clazz - object's class
name - object's name
function - object's render function

public record HudObjectType<T extends HudObject>(@NotNull Class<T extends HudObject> clazz, @NotNull String name, @NotNull BiFunction<T extends HudObject,HudPlayer,HudComponentSupplier<T extends HudObject>> function, @NotNull Function<String,T extends HudObject> stringGetter, @NotNull Supplier<Collection<T extends HudObject>> valuesSupplier) extends Record
A type of HUD element
See Also:
  • Field Details

  • Constructor Details

    • HudObjectType

      public HudObjectType(@NotNull @NotNull Class<T> clazz, @NotNull @NotNull String name, @NotNull @NotNull BiFunction<T,HudPlayer,HudComponentSupplier<T>> function, @NotNull @NotNull Function<String,T> stringGetter, @NotNull @NotNull Supplier<Collection<T>> valuesSupplier)
      Creates an instance of a HudObjectType record class.
      Parameters:
      clazz - the value for the clazz record component
      name - the value for the name record component
      function - the value for the function record component
      stringGetter - the value for the stringGetter record component
      valuesSupplier - the value for the valuesSupplier record component
  • Method Details

    • types

      @NotNull public static @NotNull @Unmodifiable Collection<HudObjectType<?>> types()
    • byName

      @Nullable public T byName(@NotNull @NotNull String name)
    • all

      @NotNull public @NotNull @Unmodifiable Collection<T> all()
    • defaultObjects

      @NotNull public @NotNull Stream<T> defaultObjects()
    • invoke

      @Internal @NotNull public @NotNull HudComponentSupplier<?> invoke(@NotNull @NotNull HudObject object, @NotNull @NotNull HudPlayer player)
      Gets supplier from an object
      Parameters:
      object - target object
      player - target player
      Returns:
      supplier
    • equals

      public boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • clazz

      @NotNull public @NotNull Class<T> clazz()
      Returns the value of the clazz record component.
      Returns:
      the value of the clazz record component
    • name

      @NotNull public @NotNull String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • function

      @NotNull public @NotNull BiFunction<T,HudPlayer,HudComponentSupplier<T>> function()
      Returns the value of the function record component.
      Returns:
      the value of the function record component
    • stringGetter

      @NotNull public @NotNull Function<String,T> stringGetter()
      Returns the value of the stringGetter record component.
      Returns:
      the value of the stringGetter record component
    • valuesSupplier

      @NotNull public @NotNull Supplier<Collection<T>> valuesSupplier()
      Returns the value of the valuesSupplier record component.
      Returns:
      the value of the valuesSupplier record component