Class OperatorBuilder<O>

java.lang.Object
org.cyclops.integrateddynamics.core.evaluate.build.OperatorBuilder<O>
Type Parameters:
O - The current output type for value propagators.

public class OperatorBuilder<O> extends Object
Immutable builder for operators. Appending the kinds "a", "b" and "c" for example will result in the base localization key of "operator.operators.MOD_ID.a.b.c.". This base key then will be suffixed with {"name", "basename"}. If the operator name would be "xyz", then you'll also need the localization keys "operator.operators.MOD_ID.a.b.c.xyz."{"name", "info"}. The actual operator function can either be set by calling function or by doing any number of calls to handle(IOperatorValuePropagator) with value propagators.
  • Constructor Details

  • Method Details

    • output

      public OperatorBuilder<O> output(IValueType outputType)
      Set the operator output value type.
      Parameters:
      outputType - The output value type.
      Returns:
      The builder instance.
    • symbol

      public OperatorBuilder<O> symbol(String symbol)
      Set the operator symbol.
      Parameters:
      symbol - The symbol for the operator.
      Returns:
      The builder instance.
    • operatorName

      public OperatorBuilder<O> operatorName(String operatorName)
      Set the operator name, used for localization.
      Parameters:
      operatorName - The operator name.
      Returns:
      The builder instance.
    • interactName

      public OperatorBuilder<O> interactName(String interactName)
      Set the unique interact name.
      Parameters:
      interactName - The unique interact name.
      Returns:
      The builder instance.
    • interactName

      public OperatorBuilder<O> interactName(String interactName, String globalInteractNamePrefix, boolean alsoPrefixLocalScope)
      Set the unique interact name.
      Parameters:
      interactName - The unique interact name.
      globalInteractNamePrefix - The prefix to use for the global interact name.
      alsoPrefixLocalScope - If the prefix should also be used for the local scope.
      Returns:
      The builder instance.
    • symbolOperator

      public OperatorBuilder<O> symbolOperator(String symbolOperator)
      Set the symbol and operator name to the given value. The symbol is used for display while the operator name is used for localization.
      Parameters:
      symbolOperator - The symbol and operator name.
      Returns:
      The builder instance.
    • symbolOperatorInteract

      public OperatorBuilder<O> symbolOperatorInteract(String symbolOperator)
      Set the symbol, operator, and unique interact name to the given value. The symbol is used for display while the operator name is used for localization.
      Parameters:
      symbolOperator - The symbol, operator, and unique name.
      Returns:
      The builder instance.
    • operatorInteract

      public OperatorBuilder<O> operatorInteract(String operatorInteract)
      Set the operator, and unique interact name to the given value.
      Parameters:
      operatorInteract - The operator and interact name.
      Returns:
      The builder instance.
    • inputTypes

      public OperatorBuilder<O> inputTypes(IValueType... inputTypes)
      Set the input types for the operator.
      Parameters:
      inputTypes - Array of value types.
      Returns:
      The builder instance.
    • inputTypes

      public OperatorBuilder<O> inputTypes(int length, IValueType defaultType)
      Set input types to a given amount of the given value type.
      Parameters:
      length - The amount of input types.
      defaultType - The input type to replicate `length` times.
      Returns:
      The builder instance.
    • inputType

      public OperatorBuilder<O> inputType(IValueType inputType)
      Set a single input type.
      Parameters:
      inputType - The input type.
      Returns:
      The builder instance.
    • function

      public OperatorBuilder<O> function(OperatorBase.IFunction function)
      Set the function the operator should use.
      Parameters:
      function - The function.
      Returns:
      The builder instance.
    • renderPattern

      public OperatorBuilder<O> renderPattern(IConfigRenderPattern renderPattern)
      Set the render pattern for this operator in guis.
      Parameters:
      renderPattern - The render pattern.
      Returns:
      The builder instance.
    • modId

      public OperatorBuilder<O> modId(String modId)
      Set the mod id, by default this will be the Integrated Dynamics mod id.
      Parameters:
      modId - The mod id.
      Returns:
      The builder instance.
    • appendKind

      public OperatorBuilder<O> appendKind(String kind)
      Append a localization key element.
      Parameters:
      kind - The string to append.
      Returns:
      The builder instance.
    • conditionalOutputTypeDeriver

      public OperatorBuilder<O> conditionalOutputTypeDeriver(OperatorBuilder.IConditionalOutputTypeDeriver conditionalOutputTypeDeriver)
      Set the conditional output type deriver.
      Parameters:
      conditionalOutputTypeDeriver - The output type deriver based on certain input. This will be used for IOperator.getConditionalOutputType(IVariable[]).
      Returns:
      The builder instance.
    • typeValidator

      public OperatorBuilder<O> typeValidator(OperatorBuilder.ITypeValidator typeValidator)
      Set the type validator.
      Parameters:
      typeValidator - The type validator. This will be used for IOperator.validateTypes(IValueType[]).
      Returns:
      The builder instance.
    • handle

      public <O2> OperatorBuilder<O2> handle(IOperatorValuePropagator<O,O2> valuePropagator)
      Add a value propagator.
      Type Parameters:
      O2 - The new output type for value propagators.
      Parameters:
      valuePropagator - The value propagator.
      Returns:
      The builder instance.
    • build

      public IOperator build()
      Build an operator from the current builder state.
      Returns:
      The built operator
    • forType

      public static OperatorBuilder<OperatorBase.SafeVariablesGetter> forType(IValueType<?> outputType)
      Create a new builder with the given output type.
      Parameters:
      outputType - The output type.
      Returns:
      The builder instance.