/** * Filter using a {@code Map}. This {@code Filter} is executed using the specified {@code Map}'s * keys and values. The keys are looked up in a normal manner respecting case. * * @param map The {@code Map} whose key/value pairs are used in the match. Maps with {@code * null} key or values are not supported. A {@code null} value is considered not present to * the filter. * @return {@code true} if the {@code Map}'s values match this filter; {@code false} otherwise. * @since 1.6 */ @Override public boolean matches(Map<String, ?> map) { switch (op) { case AND: { FilterImpl[] filters = (FilterImpl[]) value; for (FilterImpl f : filters) { if (!f.matches(map)) { return false; } } return true; } case OR: { FilterImpl[] filters = (FilterImpl[]) value; for (FilterImpl f : filters) { if (f.matches(map)) { return true; } } return false; } case NOT: { FilterImpl filter = (FilterImpl) value; return !filter.matches(map); } case SUBSTRING: case EQUAL: case GREATER: case LESS: case APPROX: { Object prop = (map == null) ? null : map.get(attr); return compare(op, prop, value); } case PRESENT: { Object prop = (map == null) ? null : map.get(attr); return prop != null; } } return false; }