Record Class ListRecipeComponent<T>

java.lang.Object
java.lang.Record
dev.latvian.mods.kubejs.recipe.component.ListRecipeComponent<T>
All Implemented Interfaces:
RecipeComponent<List<T>>

public record ListRecipeComponent<T>(RecipeComponent<T> component, boolean canWriteSelf, dev.latvian.mods.rhino.type.TypeInfo listTypeInfo, com.mojang.serialization.Codec<List<T>> listCodec, boolean conditional, IntBounds bounds, Optional<RecipeComponent<?>> spread, Optional<RecipeComponent<?>> spreadWrap) extends Record implements RecipeComponent<List<T>>
  • Field Details

  • Constructor Details

    • ListRecipeComponent

      public ListRecipeComponent(RecipeComponent<T> component, boolean canWriteSelf, dev.latvian.mods.rhino.type.TypeInfo listTypeInfo, com.mojang.serialization.Codec<List<T>> listCodec, boolean conditional, IntBounds bounds, Optional<RecipeComponent<?>> spread, Optional<RecipeComponent<?>> spreadWrap)
      Creates an instance of a ListRecipeComponent record class.
      Parameters:
      component - the value for the component record component
      canWriteSelf - the value for the canWriteSelf record component
      listTypeInfo - the value for the listTypeInfo record component
      listCodec - the value for the listCodec record component
      conditional - the value for the conditional record component
      bounds - the value for the bounds record component
      spread - the value for the spread record component
      spreadWrap - the value for the spreadWrap record component
  • Method Details

    • create

      public static <L> ListRecipeComponent<L> create(RecipeComponent<L> component, boolean canWriteSelf, boolean conditional)
    • create

      public static <L> ListRecipeComponent<L> create(RecipeComponent<L> component, boolean canWriteSelf, boolean conditional, IntBounds bounds, Optional<RecipeComponent<?>> spread)
    • type

      public RecipeComponentType<?> type()
      Specified by:
      type in interface RecipeComponent<T>
    • codec

      public com.mojang.serialization.Codec<List<T>> codec()
      Specified by:
      codec in interface RecipeComponent<T>
    • typeInfo

      public dev.latvian.mods.rhino.type.TypeInfo typeInfo()
      Description copied from interface: RecipeComponent
      Defines a description for how this component may be constructed. Type descriptions may be comprised of a primitive type such as a string, number or Java class (which may be useful if that that class has an appropriate type wrapper for it already), an array of fixed or dynamic length, a map / object, or a union of multiple types.

      Type descriptions are used by addons like ProbeJS to provide typing hints.

      Specified by:
      typeInfo in interface RecipeComponent<T>
      Returns:
      A description of how this component may be constructed
    • hasPriority

      public boolean hasPriority(RecipeMatchContext cx, Object from)
      Description copied from interface: RecipeComponent
      Declares whether this component should take priority when being considered by e.g. an EitherRecipeComponent during deserialization.
      Specified by:
      hasPriority in interface RecipeComponent<T>
      Parameters:
      cx - Script context
      from - The object to be deserialized from
      Returns:
      Whether this component should take priority
    • wrap0

      public static <T> List<T> wrap0(RecipeScriptContext cx, RecipeComponent<T> component, Object from)
    • wrap

      public List<T> wrap(RecipeScriptContext cx, Object from)
      Description copied from interface: RecipeComponent
      Method to read the value contained within this component from an input object; this may be some arbitrary value passed into a schema's constructor(s) or automatically generated builder methods. By default, it will attempt to type wrap based on RecipeComponent.typeInfo()
      Specified by:
      wrap in interface RecipeComponent<T>
      Parameters:
      cx - Script context
      from - An object to be converted to a value for this component
      Returns:
      The value read from the input
    • matches

      public boolean matches(RecipeMatchContext cx, List<T> value, ReplacementMatchInfo match)
      Specified by:
      matches in interface RecipeComponent<T>
      Parameters:
      cx - Script context
      value - The value to check
      match - The replacement match to check against
      Returns:
      true if the given value matches the given replacement match.
    • replace

      public List<T> replace(RecipeScriptContext cx, List<T> original, ReplacementMatchInfo match, Object with)
      Specified by:
      replace in interface RecipeComponent<T>
    • buildUniqueId

      public void buildUniqueId(UniqueIdBuilder builder, List<T> value)
      Specified by:
      buildUniqueId in interface RecipeComponent<T>
    • toString

      public 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
    • validate

      public void validate(RecipeValidationContext ctx, List<T> value)
      Specified by:
      validate in interface RecipeComponent<T>
    • allowEmpty

      public boolean allowEmpty()
      Specified by:
      allowEmpty in interface RecipeComponent<T>
    • isEmpty

      public boolean isEmpty(List<T> value)
      Description copied from interface: RecipeComponent
      Shallow empty check function
      Specified by:
      isEmpty in interface RecipeComponent<T>
    • spread

      public List<?> spread(List<T> value)
      Specified by:
      spread in interface RecipeComponent<T>
    • withBounds

      public ListRecipeComponent<T> withBounds(IntBounds bounds)
    • orSelf

      public ListRecipeComponent<T> orSelf()
      Specified by:
      orSelf in interface RecipeComponent<T>
    • asConditional

      public ListRecipeComponent<T> asConditional()
    • withSpread

      public ListRecipeComponent<T> withSpread(Optional<RecipeComponent<?>> spread)
    • hashCode

      public final 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
    • equals

      public final 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • component

      public RecipeComponent<T> component()
      Returns the value of the component record component.
      Returns:
      the value of the component record component
    • canWriteSelf

      public boolean canWriteSelf()
      Returns the value of the canWriteSelf record component.
      Returns:
      the value of the canWriteSelf record component
    • listTypeInfo

      public dev.latvian.mods.rhino.type.TypeInfo listTypeInfo()
      Returns the value of the listTypeInfo record component.
      Returns:
      the value of the listTypeInfo record component
    • listCodec

      public com.mojang.serialization.Codec<List<T>> listCodec()
      Returns the value of the listCodec record component.
      Returns:
      the value of the listCodec record component
    • conditional

      public boolean conditional()
      Returns the value of the conditional record component.
      Returns:
      the value of the conditional record component
    • bounds

      public IntBounds bounds()
      Returns the value of the bounds record component.
      Returns:
      the value of the bounds record component
    • spread

      public Optional<RecipeComponent<?>> spread()
      Returns the value of the spread record component.
      Returns:
      the value of the spread record component
    • spreadWrap

      public Optional<RecipeComponent<?>> spreadWrap()
      Returns the value of the spreadWrap record component.
      Returns:
      the value of the spreadWrap record component