Class ExpressionTypeFinder

  • All Implemented Interfaces:
    ExpressionVisitor

    public class ExpressionTypeFinder
    extends Object
    implements ExpressionVisitor
    Use to find sub-expressions of a particular type within a given expression. For example, the following would extract a set of variables (IdentifierExpressions) from an expression: ExpressionTypeFinder finder = new ExpressionTypeFinder(someExpression, IdentifierExpression.class); Set variables = finder.getExpressions();
    • Constructor Detail

      • ExpressionTypeFinder

        public ExpressionTypeFinder​(Expression expressionToSearch,
                                    Class expressionTypeToFind)
        Creates a new ExpressionTypeFinder
        Parameters:
        expressionToSearch - the expression to search to find sub-expressions
        expressionTypeToFind - the type of the sub-expressions to search
    • Method Detail

      • visit

        public void visit​(Expression expression)
        Implementation of the visitor design pattern. An expression will call this with itself as the expression parameter.
        Specified by:
        visit in interface ExpressionVisitor
        Parameters:
        expression -
      • getExpressions

        public LinkedHashSet<Expression> getExpressions()
        Gets a set of subexpressions of a given type
        Returns:
        a set of expressions of type expressionTypeToFind contained within expressionToSearch