Class ExpressionVariableFacade

java.lang.Object
org.cyclops.integrateddynamics.core.item.VariableFacadeBase
org.cyclops.integrateddynamics.core.item.ExpressionVariableFacade
All Implemented Interfaces:
IExpressionVariableFacade, IVariableFacade

public class ExpressionVariableFacade extends VariableFacadeBase implements IExpressionVariableFacade
Variable facade for variables defined by an expression tree.
  • Constructor Details

    • ExpressionVariableFacade

      public ExpressionVariableFacade(boolean generateId, @Nullable Expression expression)
    • ExpressionVariableFacade

      public ExpressionVariableFacade(int id, @Nullable Expression expression)
    • ExpressionVariableFacade

      public ExpressionVariableFacade(boolean generateId, @Nullable Expression expression, Map<Integer, IValueType<?>> referenceTypes, @Nullable String text)
    • ExpressionVariableFacade

      public ExpressionVariableFacade(int id, @Nullable Expression expression, Map<Integer, IValueType<?>> referenceTypes, @Nullable String text)
  • Method Details

    • getReferenceTypes

      public Map<Integer, IValueType<?>> getReferenceTypes()
      Specified by:
      getReferenceTypes in interface IExpressionVariableFacade
      Returns:
      The output types of the referenced variables, by variable id, as far as they were known when this card was written. This is only used when editing the card, evaluation always uses the actual variables.
    • getText

      @Nullable public String getText()
      Specified by:
      getText in interface IExpressionVariableFacade
      Returns:
      The text the expression was typed as, or null if it was not typed or is printed. This is only used when editing the card, and only while the text still reads as the expression.
    • getExpression

      @Nullable public Expression getExpression()
      Specified by:
      getExpression in interface IExpressionVariableFacade
      Returns:
      The expression, or null if the facade is invalid.
    • isValid

      public boolean isValid()
      Specified by:
      isValid in interface IVariableFacade
      Returns:
      If this is a valid reference.
    • getReferencedVariable

      @Nullable protected IVariable<?> getReferencedVariable(INetwork network, IPartNetwork partNetwork, int variableId)
    • getVariable

      public <V extends IValue> IVariable<V> getVariable(INetwork network, IPartNetwork partNetwork)
      Description copied from interface: IVariableFacade
      Get the variable.
      Specified by:
      getVariable in interface IVariableFacade
      Type Parameters:
      V - The value type.
      Parameters:
      network - The network used to look for the variable.
      partNetwork - The part network used to look for the variable.
      Returns:
      The variable.
    • buildVariable

      @Nullable protected IVariable<?> buildVariable(INetwork network, IPartNetwork partNetwork)
    • validate

      public void validate(INetwork network, IPartNetwork partNetwork, IVariableFacade.IValidator validator, IValueType containingValueType)
      Description copied from interface: IVariableFacade
      Check if this facade is valid, otherwise notify the validator of any errors.
      Specified by:
      validate in interface IVariableFacade
      Parameters:
      network - The network used to look for the variable.
      partNetwork - The part network used to look for the variable.
      validator - The object to notify errors to.
      containingValueType - The value type in which this variable facade is being used.
    • getRootOutputType

      public IValueType<?> getRootOutputType()
      Returns:
      The output type of the root, inferred without knowledge of referenced variables.
    • getKnownRootOutputType

      public IValueType<?> getKnownRootOutputType()
      Returns:
      The output type of the root, inferred with the types that referenced variables had when the card was written.
    • getOutputType

      public IValueType getOutputType()
      Specified by:
      getOutputType in interface IVariableFacade
      Returns:
      The output type of this variable facade.
    • printExpression

      public String printExpression()
      Returns:
      The expression pretty-printed with labels.
    • constructClient

      protected IVariableFacadeClient constructClient()
      Specified by:
      constructClient in class VariableFacadeBase
    • appendHoverText

      public void appendHoverText(Consumer<net.minecraft.network.chat.Component> tooltipAdder, net.minecraft.world.item.Item.TooltipContext context)
      Description copied from interface: IVariableFacade
      Add information about this variable facade to the list.
      Specified by:
      appendHoverText in interface IVariableFacade
      Overrides:
      appendHoverText in class VariableFacadeBase
      Parameters:
      tooltipAdder - The list to add lines to.
      context - The context.
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class VariableFacadeBase
    • getRootOperator

      @Nullable public IOperator getRootOperator()
      Returns:
      The root operator if the root is an operator node, otherwise null.