FilterExpression { public static boolean isValid(String expression) { try { FilterExpression.of(expression); return true; } catch (IllegalArgumentException e) { return false; } } private  FilterExpression(String expressionString, FilterParser parser); private  FilterExpression(); static FilterExpression alwaysTrue(); static FilterExpression of(String expression); boolean evaluate(AttributesMap attributes); @Override String toString(); static boolean isValid(String expression); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void testIsValid() { assertTrue(FilterExpression.isValid("a")); assertTrue(FilterExpression.isValid("a|b")); assertTrue(FilterExpression.isValid("!a")); assertTrue(FilterExpression.isValid("(((a)))")); assertFalse(FilterExpression.isValid("|")); assertFalse(FilterExpression.isValid("a|")); assertFalse(FilterExpression.isValid("|b")); assertFalse(FilterExpression.isValid("!|")); assertFalse(FilterExpression.isValid("!|b")); assertFalse(FilterExpression.isValid("((a)")); }