RangeCondition implements Predicate<Wrapper<?>> { static <X extends Number & Comparable<X>> RangeCondition<X> moreThan(final Function<Wrapper<?>, X> value, final Domain<X> allowedValues, final X threshold) { if (!allowedValues.test(threshold)) { throw new IllegalArgumentException("Threshold " + threshold + " does not fit " + allowedValues); } return new RangeCondition<>(value, v -> v.compareTo(threshold) > 0, "Range: (" + threshold + "; +inf.)"); } private  RangeCondition(final Function<Wrapper<?>, T> accessor, final Predicate<T> acceptor,
            final String toString); @Override boolean test(final Wrapper<?> wrapper); @Override String toString();  }
@Test void moreThan() { final RangeCondition<Integer> c = RangeCondition.moreThan(Wrapper::getOriginalTermInMonths, new Domain<>(Integer.class, 0, null), 5); final Wrapper<?> w = mock(Wrapper.class); when(w.getOriginalTermInMonths()).thenReturn(5); assertThat(c).rejects(w); when(w.getOriginalTermInMonths()).thenReturn(6); assertThat(c).accepts(w); }