DynamoFilterUtil { public static List<Filter> flattenAnd(And and) { List<Filter> children = new ArrayList<>(); for (Filter f : and.getFilters()) { if (f instanceof And) { And childAnd = (And) f; List<Filter> temp = flattenAnd(childAnd); children.addAll(temp); } else { children.add(f); } } return children; } private  DynamoFilterUtil(); static Filter extractFilter(Filter filter, String propertyId); static List<Filter> flattenAnd(And and); static void removeFilters(Filter filter, String... propertyIds); static void replaceMasterAndDetailFilters(Filter filter, EntityModel<?> entityModel); static void replaceFilter(Filter original, Filter newFilter, String propertyId, boolean firstOnly);  }
@Test public void testFlattenAnd() { com.ocs.dynamo.filter.Like compare = new com.ocs.dynamo.filter.Like("prop1", "someString"); com.ocs.dynamo.filter.And and = new com.ocs.dynamo.filter.And(compare, new com.ocs.dynamo.filter.Compare.Equal("prop3", "someString")); com.ocs.dynamo.filter.Like compare2 = new com.ocs.dynamo.filter.Like("prop1", "someString2"); com.ocs.dynamo.filter.And and2 = new com.ocs.dynamo.filter.And(and, compare2); List<Filter> flattened2 = DynamoFilterUtil.flattenAnd(and); assertEquals(2, flattened2.size()); assertEquals(compare, flattened2.get(0)); List<Filter> flattened = DynamoFilterUtil.flattenAnd(and2); assertEquals(3, flattened.size()); assertEquals(compare, flattened.get(0)); assertEquals(compare2, flattened.get(2)); }