@Test public void filterConditionShouldMapWhenTo() { String to = "recipient@james.org"; Stream<SearchQuery.Criterion> criteria = new FilterToCriteria().convert(FilterCondition.builder() .to(to) .build()); assertThat(criteria).containsExactly(SearchQuery.address(AddressType.To, to)); }
public Stream<Criterion> convert(Filter filter) { if (filter instanceof FilterCondition) { return convertCondition((FilterCondition) filter); } if (filter instanceof FilterOperator) { return Stream.of(convertOperator((FilterOperator) filter)); } throw new RuntimeException("Unknown filter: " + filter.getClass()); }
FilterToCriteria { public Stream<Criterion> convert(Filter filter) { if (filter instanceof FilterCondition) { return convertCondition((FilterCondition) filter); } if (filter instanceof FilterOperator) { return Stream.of(convertOperator((FilterOperator) filter)); } throw new RuntimeException("Unknown filter: " + filter.getClass()); } }
FilterToCriteria { public Stream<Criterion> convert(Filter filter) { if (filter instanceof FilterCondition) { return convertCondition((FilterCondition) filter); } if (filter instanceof FilterOperator) { return Stream.of(convertOperator((FilterOperator) filter)); } throw new RuntimeException("Unknown filter: " + filter.getClass()); }  }
FilterToCriteria { public Stream<Criterion> convert(Filter filter) { if (filter instanceof FilterCondition) { return convertCondition((FilterCondition) filter); } if (filter instanceof FilterOperator) { return Stream.of(convertOperator((FilterOperator) filter)); } throw new RuntimeException("Unknown filter: " + filter.getClass()); }  Stream<Criterion> convert(Filter filter); }
FilterToCriteria { public Stream<Criterion> convert(Filter filter) { if (filter instanceof FilterCondition) { return convertCondition((FilterCondition) filter); } if (filter instanceof FilterOperator) { return Stream.of(convertOperator((FilterOperator) filter)); } throw new RuntimeException("Unknown filter: " + filter.getClass()); }  Stream<Criterion> convert(Filter filter);  }