Record Class ReplacementRequest<T>
java.lang.Object
java.lang.Record
com.blamejared.crafttweaker.api.recipe.replacement.ReplacementRequest<T>
- Type Parameters:
T- The type of the object that will undergo replacement.- Record Components:
component- TheIRecipeComponentfor which this replacer should be carried out.strategy- TheITargetingStrategythat indicates how the components should be targeted.target- APredicatethat determines the element that will be targeted for replacement.replacer- AUnaryOperatorthat is responsible for performing the actual replacement.
public record ReplacementRequest<T>(IRecipeComponent<T> component, ITargetingStrategy strategy, DescriptivePredicate<T> target, DescriptiveUnaryOperator<T> replacer)
extends Record
Indicates a request that needs to be carried out by the
Replacer.- Since:
- 10.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionReplacementRequest(IRecipeComponent<T> component, ITargetingStrategy strategy, DescriptivePredicate<T> target, DescriptiveUnaryOperator<T> replacer) Creates an instance of aReplacementRequestrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanapplyRequest(IDecomposedRecipe recipe) Applies this request to the givenIDecomposedRecipe, if possible.Returns the value of thecomponentrecord component.describe()Describes this request in a human-readable format for log output.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.replacer()Returns the value of thereplacerrecord component.strategy()Returns the value of thestrategyrecord component.target()Returns the value of thetargetrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ReplacementRequest
public ReplacementRequest(IRecipeComponent<T> component, ITargetingStrategy strategy, DescriptivePredicate<T> target, DescriptiveUnaryOperator<T> replacer) Creates an instance of aReplacementRequestrecord class.
-
-
Method Details
-
applyRequest
Applies this request to the givenIDecomposedRecipe, if possible.If the recipe's components do not contain the
component()this request is targeting, then replacement fails immediately. Otherwise, a best-effort attempt shall be performed.- Parameters:
recipe- The recipe that should undergo replacement.- Returns:
- Whether the replacement was successful or not.
- Since:
- 10.0.0
-
describe
Describes this request in a human-readable format for log output.- Returns:
- A human-readable description.
- Since:
- 10.0.0
-
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. -
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. All components in this record class are compared withObjects::equals(Object,Object). -
component
Returns the value of thecomponentrecord component.- Returns:
- the value of the
componentrecord component
-
strategy
Returns the value of thestrategyrecord component.- Returns:
- the value of the
strategyrecord component
-
target
Returns the value of thetargetrecord component.- Returns:
- the value of the
targetrecord component
-
replacer
Returns the value of thereplacerrecord component.- Returns:
- the value of the
replacerrecord component
-