Class ExpressionOperator

java.lang.Object
org.cyclops.integrateddynamics.core.evaluate.operator.OperatorBase
org.cyclops.integrateddynamics.core.evaluate.expression.tree.ExpressionOperator
All Implemented Interfaces:
IOperator

public class ExpressionOperator extends OperatorBase
An operator defined by an expression tree with parameters. The parameters of the expression are the inputs of this operator.
  • Constructor Details

    • ExpressionOperator

      public ExpressionOperator(Expression expression, it.unimi.dsi.fastutil.ints.Int2ObjectMap<IVariable<?>> refs, IValueType<?> outputType)
      Parameters:
      expression - The expression, its parameters define the operator inputs.
      refs - Bound variables for references in the expression.
      outputType - The output type.
  • Method Details

    • of

      public static ExpressionOperator of(Expression expression, it.unimi.dsi.fastutil.ints.Int2ObjectMap<IVariable<?>> refs)
      Create an operator for the given expression, inferring its output type.
      Parameters:
      expression - The expression.
      refs - Bound variables for references in the expression.
      Returns:
      The operator.
    • of

      public static ExpressionOperator of(Expression expression)
    • getUnlocalizedType

      protected String getUnlocalizedType()
      Specified by:
      getUnlocalizedType in class OperatorBase
    • getExpression

      public Expression getExpression()
    • getRefs

      public it.unimi.dsi.fastutil.ints.Int2ObjectMap<IVariable<?>> getRefs()
    • getLocalizedNameFull

      public net.minecraft.network.chat.MutableComponent getLocalizedNameFull()
      Specified by:
      getLocalizedNameFull in interface IOperator
      Overrides:
      getLocalizedNameFull in class OperatorBase
      Returns:
      The localized full name for this operator, includes category name
    • loadTooltip

      public void loadTooltip(Consumer<net.minecraft.network.chat.Component> tooltipAdder, boolean appendOptionalInfo)
      Description copied from interface: IOperator
      Add tooltip lines for this aspect when hovered in a gui.
      Specified by:
      loadTooltip in interface IOperator
      Overrides:
      loadTooltip in class OperatorBase
      Parameters:
      tooltipAdder - The list to add lines to.
      appendOptionalInfo - If shift-to-show info should be added.
    • getMaterializedExpression

      public Expression getMaterializedExpression() throws EvaluationException
      Returns:
      The expression where all references are replaced by their current values.
      Throws:
      EvaluationException - If a referenced value could not be evaluated.
    • materialize

      public IOperator materialize() throws EvaluationException
      Description copied from interface: IOperator
      Materialize this operator so that it can exist without any external references.
      Specified by:
      materialize in interface IOperator
      Overrides:
      materialize in class OperatorBase
      Returns:
      The materialized operator.
      Throws:
      EvaluationException - if materialization fails because of a variable evaluation.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class OperatorBase