Filters { public static Criterion allEq(Map<String, ?> vals) { List<Criterion> filters = new ArrayList<Criterion>(vals.size()); for(Entry<String, ?> entry : vals.entrySet()) { filters.add(eq(entry.getKey(), entry.getValue())); } return and(filters); } private  Filters(); static Criterion and(Collection<? extends Criterion> f); static Criterion and(Criterion... f); static Criterion or(Collection<? extends Criterion> f); static Criterion or(Criterion... f); static Criterion not(Criterion f); static Criterion eq(String attr, Object val); static Criterion allEq(Map<String, ?> vals); static Criterion anyEq(Map<String, ?> vals); static Criterion ne(String attr, Object val); static Criterion approx(String attr, Object val); static Criterion ge(final String attr, final Object val); static Criterion le(String attr, Object val); static Criterion exists(String attr); static Criterion is(Class<?> type); static Criterion is(String type); static Criterion like(String attr, Object val, LikeCriterion.MatchMode mode); static Criterion like(String attr, Object val); static Criterion raw(String f);  }
@Test public void testAllEq() throws Exception { Map<String, String> attrs = new LinkedHashMap<String, String>(); attrs.put("a", "b"); attrs.put("c", "d"); Criterion criterion = allEq(attrs); assertThat(criterion.value(), equalTo("(&(a=b)(c=d))")); assertThat(criterion.filter(), notNullValue()); }