FilterSatisfiedMask { @Nonnull public FilterSatisfiedMask getChild(@Nonnull QueryComponent childFilter) { for (FilterSatisfiedMask child : children) { if (child.getFilter() == childFilter) { return child; } } throw new FilterNotFoundException(childFilter); } private  FilterSatisfiedMask(@Nonnull QueryComponent filter, @Nonnull List<FilterSatisfiedMask> children, boolean satisfied); boolean isSatisfied(); void setSatisfied(boolean satisfied); @Nullable KeyExpression getExpression(); void setExpression(@Nullable KeyExpression expression); @Nonnull QueryComponent getFilter(); @Nonnull List<FilterSatisfiedMask> getChildren(); @Nonnull FilterSatisfiedMask getChild(@Nonnull QueryComponent childFilter); void reset(); @Nonnull List<QueryComponent> getUnsatisfiedFilters(); @Nullable QueryComponent getUnsatisfiedFilter(); boolean allSatisfied(); void mergeWith(@Nonnull FilterSatisfiedMask other); @Override String toString(); @Nonnull static FilterSatisfiedMask of(@Nonnull QueryComponent filter);  }
@Test public void getChild() { final QueryComponent fieldA = Query.field("a").equalsValue("dummy_value"); FilterSatisfiedMask fieldAMask = FilterSatisfiedMask.of(fieldA); assertThrows(FilterSatisfiedMask.FilterNotFoundException.class, () -> fieldAMask.getChild(Query.field("b").equalsValue("blah"))); final QueryComponent nestedFieldB = Query.field("b").matches(fieldA); FilterSatisfiedMask nestedFieldBMask = FilterSatisfiedMask.of(nestedFieldB); assertSame(fieldA, nestedFieldBMask.getChild(fieldA).getFilter()); assertThrows(FilterSatisfiedMask.FilterNotFoundException.class, () -> nestedFieldBMask.getChild(Query.field("a").equalsValue("dummy_value"))); final QueryComponent andComponent = Query.and(nestedFieldB, Query.field("c").equalsValue("something_else")); FilterSatisfiedMask andMask = FilterSatisfiedMask.of(andComponent); assertSame(nestedFieldB, andMask.getChild(nestedFieldB).getFilter()); assertThrows(FilterSatisfiedMask.FilterNotFoundException.class, () -> andMask.getChild(Query.field("c").equalsValue("something_else"))); }