Record Class EitherRecipeComponent<H,L>

java.lang.Object
java.lang.Record
dev.latvian.mods.kubejs.recipe.component.EitherRecipeComponent<H,L>
All Implemented Interfaces:
RecipeComponent<com.mojang.datafixers.util.Either<H,L>>

public record EitherRecipeComponent<H,L>(RecipeComponent<H> left, RecipeComponent<L> right, com.mojang.serialization.Codec<com.mojang.datafixers.util.Either<H,L>> codec, dev.latvian.mods.rhino.type.TypeInfo typeInfo) extends Record implements RecipeComponent<com.mojang.datafixers.util.Either<H,L>>
  • Field Details

  • Constructor Details

    • EitherRecipeComponent

      public EitherRecipeComponent(RecipeComponent<H> left, RecipeComponent<L> right)
    • EitherRecipeComponent

      public EitherRecipeComponent(RecipeComponent<H> left, RecipeComponent<L> right, com.mojang.serialization.Codec<com.mojang.datafixers.util.Either<H,L>> codec, dev.latvian.mods.rhino.type.TypeInfo typeInfo)
      Creates an instance of a EitherRecipeComponent record class.
      Parameters:
      left - the value for the left record component
      right - the value for the right record component
      codec - the value for the codec record component
      typeInfo - the value for the typeInfo record component
  • Method Details

    • type

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

      public com.mojang.datafixers.util.Either<H,L> 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<H>
      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, com.mojang.datafixers.util.Either<H,L> value, ReplacementMatchInfo match)
      Specified by:
      matches in interface RecipeComponent<H>
      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 com.mojang.datafixers.util.Either<H,L> replace(RecipeScriptContext cx, com.mojang.datafixers.util.Either<H,L> original, ReplacementMatchInfo match, Object with)
      Specified by:
      replace in interface RecipeComponent<H>
    • buildUniqueId

      public void buildUniqueId(UniqueIdBuilder builder, com.mojang.datafixers.util.Either<H,L> value)
      Specified by:
      buildUniqueId in interface RecipeComponent<H>
    • validate

      public void validate(RecipeValidationContext ctx, com.mojang.datafixers.util.Either<H,L> value)
      Specified by:
      validate in interface RecipeComponent<H>
    • 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
    • toString

      public String toString(OpsContainer ops, com.mojang.datafixers.util.Either<H,L> value)
      Specified by:
      toString in interface RecipeComponent<H>
    • spread

      public List<?> spread(com.mojang.datafixers.util.Either<H,L> value)
      Specified by:
      spread in interface RecipeComponent<H>
    • 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. 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.
    • left

      public RecipeComponent<H> left()
      Returns the value of the left record component.
      Returns:
      the value of the left record component
    • right

      public RecipeComponent<L> right()
      Returns the value of the right record component.
      Returns:
      the value of the right record component
    • codec

      public com.mojang.serialization.Codec<com.mojang.datafixers.util.Either<H,L>> codec()
      Returns the value of the codec record component.
      Specified by:
      codec in interface RecipeComponent<H>
      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<H>
      Returns:
      the value of the typeInfo record component