ToDoubleNullableImpl implements NullableExpression<T, ToDouble<T>>, ToDoubleNullable<T> { @Override public int compare(T first, T second) { final boolean f = isNull(first); final boolean s = isNull(second); if (f && s) return 0; else if (f) return 1; else if (s) return -1; else return Double.compare( original.applyAsDouble(first), original.applyAsDouble(second) ); } ToDoubleNullableImpl(ToDouble<T> original, Predicate<T> isNull); @Override ToDouble<T> inner(); @Override Predicate<T> isNullPredicate(); @Override Double apply(T t); @Override double applyAsDouble(T t); @Override ToDouble<T> orThrow(); @Override ToDouble<T> orElseGet(ToDouble<T> getter); @Override ToDouble<T> orElse(Double value); @Override ToDoubleNullable<T> mapIfPresent(DoubleUnaryOperator mapper); @Override long hash(T object); @Override int compare(T first, T second); @Override boolean isNull(T object); @Override boolean isNotNull(T object); @Override boolean equals(Object o); @Override int hashCode();  }
@Test void compare() { assertEquals(0, instance.compare(null, null)); assertEquals(1, instance.compare(null, "test")); assertEquals(-1, instance.compare("test", null)); assertEquals(0, instance.compare("test", "test")); assertEquals(1, instance.compare("test", "a")); assertEquals(-1, instance.compare("a", "test")); }