Class Literal

    • Method Detail

      • booleanLiteral

        public static Literal booleanLiteral​(boolean value)
        Constructs a bool literal from a boolean value.
        Parameters:
        value - the boolean value.
        Returns:
        the bool literal.
      • integerLiteral

        public static Literal integerLiteral​(int value)
        Constructs an integer literal from an integer value.
        Parameters:
        value - the integer value.
        Returns:
        the integer literal.
      • recordLiteral

        public static Literal recordLiteral​(java.util.Map<Identifier,​Literal> record)
        Constructs a record literal of values.
        Parameters:
        record - a map of values to be converted to a record.
        Returns:
        the record literal.
      • stringLiteral

        public static Literal stringLiteral​(Template value)
        Constructs a string literal from a Template value.
        Parameters:
        value - the template value.
        Returns:
        the string literal.
      • tupleLiteral

        public static Literal tupleLiteral​(java.util.List<Literal> values)
        Constructs a tuple literal of values.
        Parameters:
        values - the values.
        Returns:
        the tuple literal.
      • asBooleanLiteral

        public java.util.Optional<java.lang.Boolean> asBooleanLiteral()
      • asIntegerLiteral

        public java.util.Optional<java.lang.Integer> asIntegerLiteral()
      • asRecordLiteral

        public java.util.Optional<java.util.Map<Identifier,​Literal>> asRecordLiteral()
      • asStringLiteral

        public java.util.Optional<Template> asStringLiteral()
      • asTupleLiteral

        public java.util.Optional<java.util.List<Literal>> asTupleLiteral()
      • accept

        public <R> R accept​(ExpressionVisitor<R> visitor)
        Description copied from class: Expression
        Invoke the ExpressionVisitor functions for this expression.
        Specified by:
        accept in class Expression
        Type Parameters:
        R - the visitor return type.
        Parameters:
        visitor - the visitor to be invoked.
        Returns:
        the return value of the visitor.
      • accept

        public abstract <T> T accept​(LiteralVisitor<T> visitor)
      • fromNode

        public static Literal fromNode​(Node node)
        Constructs a literal from a Node based on the Node's type.
        Parameters:
        node - a node to construct as a literal.
        Returns:
        the literal representation of the node.
      • evaluate

        public Value evaluate​(RuleEvaluator evaluator)
        Parameters:
        evaluator - the rule-set evaluator.
        Returns:
        the resulting value.