Record Class MapRecipeComponent<K,V>

java.lang.Object
java.lang.Record
dev.latvian.mods.kubejs.recipe.component.MapRecipeComponent<K,V>
All Implemented Interfaces:
RecipeComponent<TinyMap<K,V>>

public record MapRecipeComponent<K,V>(RecipeComponent<K> key, RecipeComponent<V> component, boolean patternKey, IntBounds bounds, com.mojang.serialization.Codec<TinyMap<K,V>> codec, dev.latvian.mods.rhino.type.TypeInfo typeInfo) extends Record implements RecipeComponent<TinyMap<K,V>>
  • Field Details

  • Constructor Details

    • MapRecipeComponent

      public MapRecipeComponent(RecipeComponent<K> key, RecipeComponent<V> component, IntBounds bounds, boolean patternKey)
    • MapRecipeComponent

      public MapRecipeComponent(RecipeComponent<K> key, RecipeComponent<V> component, boolean patternKey, IntBounds bounds, com.mojang.serialization.Codec<TinyMap<K,V>> codec, dev.latvian.mods.rhino.type.TypeInfo typeInfo)
      Creates an instance of a MapRecipeComponent record class.
      Parameters:
      key - the value for the key record component
      component - the value for the component record component
      patternKey - the value for the patternKey record component
      bounds - the value for the bounds record component
      codec - the value for the codec record component
      typeInfo - the value for the typeInfo record component
  • Method Details

    • of

      public static <K, V> MapRecipeComponent<K,V> of(RecipeComponent<K> key, RecipeComponent<V> component, IntBounds bounds)
    • patternOf

      public static <V> MapRecipeComponent<Character,V> patternOf(RecipeComponent<V> component, IntBounds bounds)
    • type

      public RecipeComponentType<?> type()
      Specified by:
      type in interface RecipeComponent<K>
    • wrap

      public TinyMap<K,V> 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<K>
      Parameters:
      cx - Script context
      from - An object to be converted to a value for this component
      Returns:
      The value read from the input
    • validate

      public void validate(RecipeValidationContext ctx, TinyMap<K,V> value)
      Specified by:
      validate in interface RecipeComponent<K>
    • allowEmpty

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

      public boolean isEmpty(TinyMap<K,V> value)
      Description copied from interface: RecipeComponent
      Shallow empty check function
      Specified by:
      isEmpty in interface RecipeComponent<K>
    • matches

      public boolean matches(RecipeMatchContext cx, TinyMap<K,V> value, ReplacementMatchInfo match)
      Specified by:
      matches in interface RecipeComponent<K>
      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 TinyMap<K,V> replace(RecipeScriptContext cx, TinyMap<K,V> original, ReplacementMatchInfo match, Object with)
      Specified by:
      replace in interface RecipeComponent<K>
    • buildUniqueId

      public void buildUniqueId(UniqueIdBuilder builder, TinyMap<K,V> value)
      Specified by:
      buildUniqueId in interface RecipeComponent<K>
    • 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
    • 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.
    • key

      public RecipeComponent<K> key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component
    • component

      public RecipeComponent<V> component()
      Returns the value of the component record component.
      Returns:
      the value of the component record component
    • patternKey

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

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

      public com.mojang.serialization.Codec<TinyMap<K,V>> codec()
      Returns the value of the codec record component.
      Specified by:
      codec in interface RecipeComponent<K>
      Returns:
      the value of the codec record component
    • typeInfo

      public dev.latvian.mods.rhino.type.TypeInfo typeInfo()
      Returns the value of the typeInfo record component.
      Specified by:
      typeInfo in interface RecipeComponent<K>
      Returns:
      the value of the typeInfo record component