@Test public void filterConditionShouldMapWhenNotOperator() { String from = "sender@james.org"; String to = "recipient@james.org"; String subject = "subject"; Filter complexFilter = FilterOperator.not( FilterCondition.builder() .from(from) .to(to) .subject(subject) .build()); Stream<SearchQuery.Criterion> criteria = new FilterToCriteria().convert(complexFilter); assertThat(criteria).containsExactly(SearchQuery.not(ImmutableList.of( SearchQuery.address(AddressType.From, from), SearchQuery.address(AddressType.To, to), SearchQuery.headerContains("Subject", subject)))); }
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);  }