class 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());
    }

}