ToShortNullableImpl implements NullableExpression<T, ToShort<T>>, ToShortNullable<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 Short.compare( original.applyAsShort(first), original.applyAsShort(second) ); } ToShortNullableImpl(ToShort<T> original, Predicate<T> isNull); @Override ToShort<T> inner(); @Override Predicate<T> isNullPredicate(); @Override Short apply(T t); @Override short applyAsShort(T t); @Override ToShort<T> orThrow(); @Override ToShort<T> orElseGet(ToShort<T> getter); @Override ToShort<T> orElse(Short value); @Override ToDoubleNullable<T> mapToDoubleIfPresent(ShortToDoubleFunction mapper); @Override ToShortNullable<T> mapIfPresent(ShortUnaryOperator 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("test".length() - "a".length(), instance.compare("test", "a")); assertEquals("a".length() - "test".length(), instance.compare("a", "test")); }