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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionListRecipeComponent(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 aListRecipeComponentrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbounds()Returns the value of theboundsrecord component.voidbuildUniqueId(UniqueIdBuilder builder, List<T> value) booleanReturns the value of thecanWriteSelfrecord component.codec()Returns the value of thecomponentrecord component.booleanReturns the value of theconditionalrecord component.static <L> ListRecipeComponent<L> create(RecipeComponent<L> component, boolean canWriteSelf, boolean conditional) static <L> ListRecipeComponent<L> create(RecipeComponent<L> component, boolean canWriteSelf, boolean conditional, IntBounds bounds, Optional<RecipeComponent<?>> spread) final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanhasPriority(RecipeMatchContext cx, Object from) Declares whether this component should take priority when being considered by e.g.booleanShallow empty check functionReturns the value of thelistCodecrecord component.dev.latvian.mods.rhino.type.TypeInfoReturns the value of thelistTypeInforecord component.booleanmatches(RecipeMatchContext cx, List<T> value, ReplacementMatchInfo match) orSelf()replace(RecipeScriptContext cx, List<T> original, ReplacementMatchInfo match, Object with) spread()Returns the value of thespreadrecord component.List<?> Returns the value of thespreadWraprecord component.toString()Returns a string representation of this record class.type()dev.latvian.mods.rhino.type.TypeInfotypeInfo()Defines a description for how this component may be constructed.voidvalidate(RecipeValidationContext ctx, List<T> value) withBounds(IntBounds bounds) withSpread(Optional<RecipeComponent<?>> spread) wrap(RecipeScriptContext cx, Object from) Method to read the value contained within this component from an input object; this may be some arbitrary value passed into aschema'sconstructor(s) or automatically generated builder methods.static <T> List<T> wrap0(RecipeScriptContext cx, RecipeComponent<T> component, Object from) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface dev.latvian.mods.kubejs.recipe.component.RecipeComponent
asConditionalList, asConditionalListOrSelf, asList, asListOrSelf, asMap, asPatternKey, createBuilder, inputKey, isIgnored, key, or, otherKey, outputKey, readFromJson, toString, withCodec, writeToJson
-
Field Details
-
TYPE
-
-
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 aListRecipeComponentrecord class.- Parameters:
component- the value for thecomponentrecord componentcanWriteSelf- the value for thecanWriteSelfrecord componentlistTypeInfo- the value for thelistTypeInforecord componentlistCodec- the value for thelistCodecrecord componentconditional- the value for theconditionalrecord componentbounds- the value for theboundsrecord componentspread- the value for thespreadrecord componentspreadWrap- the value for thespreadWraprecord 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
- Specified by:
typein interfaceRecipeComponent<T>
-
codec
- Specified by:
codecin interfaceRecipeComponent<T>
-
typeInfo
public dev.latvian.mods.rhino.type.TypeInfo typeInfo()Description copied from interface:RecipeComponentDefines 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:
typeInfoin interfaceRecipeComponent<T>- Returns:
- A description of how this component may be constructed
-
hasPriority
Description copied from interface:RecipeComponentDeclares whether this component should take priority when being considered by e.g. anEitherRecipeComponentduring deserialization.- Specified by:
hasPriorityin interfaceRecipeComponent<T>- Parameters:
cx- Script contextfrom- The object to be deserialized from- Returns:
- Whether this component should take priority
-
wrap0
-
wrap
Description copied from interface:RecipeComponentMethod to read the value contained within this component from an input object; this may be some arbitrary value passed into aschema'sconstructor(s) or automatically generated builder methods. By default, it will attempt to type wrap based onRecipeComponent.typeInfo()- Specified by:
wrapin interfaceRecipeComponent<T>- Parameters:
cx- Script contextfrom- An object to be converted to a value for this component- Returns:
- The value read from the input
-
matches
- Specified by:
matchesin interfaceRecipeComponent<T>- Parameters:
cx- Script contextvalue- The value to checkmatch- 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:
replacein interfaceRecipeComponent<T>
-
buildUniqueId
- Specified by:
buildUniqueIdin interfaceRecipeComponent<T>
-
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. -
validate
- Specified by:
validatein interfaceRecipeComponent<T>
-
allowEmpty
public boolean allowEmpty()- Specified by:
allowEmptyin interfaceRecipeComponent<T>
-
isEmpty
Description copied from interface:RecipeComponentShallow empty check function- Specified by:
isEmptyin interfaceRecipeComponent<T>
-
spread
- Specified by:
spreadin interfaceRecipeComponent<T>
-
withBounds
-
orSelf
- Specified by:
orSelfin interfaceRecipeComponent<T>
-
asConditional
-
withSpread
-
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
component
Returns the value of thecomponentrecord component.- Returns:
- the value of the
componentrecord component
-
canWriteSelf
public boolean canWriteSelf()Returns the value of thecanWriteSelfrecord component.- Returns:
- the value of the
canWriteSelfrecord component
-
listTypeInfo
public dev.latvian.mods.rhino.type.TypeInfo listTypeInfo()Returns the value of thelistTypeInforecord component.- Returns:
- the value of the
listTypeInforecord component
-
listCodec
Returns the value of thelistCodecrecord component.- Returns:
- the value of the
listCodecrecord component
-
conditional
public boolean conditional()Returns the value of theconditionalrecord component.- Returns:
- the value of the
conditionalrecord component
-
bounds
Returns the value of theboundsrecord component.- Returns:
- the value of the
boundsrecord component
-
spread
Returns the value of thespreadrecord component.- Returns:
- the value of the
spreadrecord component
-
spreadWrap
Returns the value of thespreadWraprecord component.- Returns:
- the value of the
spreadWraprecord component
-