All Implemented Interfaces:
Serializable

public final class IfNode extends CompositeNode
A conditional branch of a ranking expression.
Author:
Simon Thoresen Hult, bratseth
See Also:
  • Constructor Details

    • IfNode

      public IfNode(ExpressionNode condition, ExpressionNode trueExpression, ExpressionNode falseExpression)
    • IfNode

      public IfNode(ExpressionNode condition, ExpressionNode trueExpression, ExpressionNode falseExpression, Double trueProbability)
      Creates a new condition node.
      Parameters:
      condition - the condition of this
      trueExpression - the expression to evaluate if the comparison is true
      falseExpression - the expression to evaluate if the comparison is false
      trueProbability - the probability that the condition will evaluate to true, or null if not known.
      Throws:
      IllegalArgumentException - if trueProbability is non-null and not between 0.0 and 1.0
  • Method Details

    • children

      public List<ExpressionNode> children()
      Description copied from class: CompositeNode
      Returns a read-only list containing the immediate children of this composite.
      Specified by:
      children in class CompositeNode
      Returns:
      The children of this.
    • getCondition

      public ExpressionNode getCondition()
    • getTrueExpression

      public ExpressionNode getTrueExpression()
    • getFalseExpression

      public ExpressionNode getFalseExpression()
    • getTrueProbability

      public Double getTrueProbability()
      The average probability that the condition of this node will evaluate to true, or null if not known
    • toString

      public StringBuilder toString(StringBuilder string, SerializationContext context, Deque<String> path, CompositeNode parent)
      Description copied from class: ExpressionNode
      Returns this in serialized form.
      Specified by:
      toString in class ExpressionNode
      Parameters:
      string - the StringBuilder that will be appended to
      context - the serialization context
      path - the call path to this, used for cycle detection, or null if this is a root
      parent - the parent node of this, or null if it is a root
      Returns:
      the main script, referring to script instances.
    • type

      public com.yahoo.tensor.TensorType type(com.yahoo.tensor.evaluation.TypeContext<Reference> context)
      Description copied from class: ExpressionNode
      Returns the type this will return if evaluated with the given context.
      Specified by:
      type in class ExpressionNode
      Parameters:
      context - the variable type bindings to use for this evaluation
    • evaluate

      public Value evaluate(Context context)
      Description copied from class: ExpressionNode
      Returns the value of evaluating this expression over the given context.
      Specified by:
      evaluate in class ExpressionNode
      Parameters:
      context - the variable bindings to use for this evaluation
    • setChildren

      public IfNode setChildren(List<ExpressionNode> children)
      Description copied from class: CompositeNode
      Returns a copy of this where the children is replaced by the given children.
      Specified by:
      setChildren in class CompositeNode
    • hashCode

      public int hashCode()
      Description copied from class: ExpressionNode
      Returns a hashcode computed from the data in this
      Specified by:
      hashCode in class ExpressionNode