ToIntNullableImpl implements NullableExpression<T, ToInt<T>>, ToIntNullable<T> { @Override public boolean equals(Object o) { if (this == o) return true; else if (!(o instanceof NullableExpression)) return false; final NullableExpression<?, ?> that = (NullableExpression<?, ?>) o; return Objects.equals(original, that.inner()) && Objects.equals(isNull, that.isNullPredicate()); } ToIntNullableImpl(ToInt<T> original, Predicate<T> isNull); @Override ToInt<T> inner(); @Override Predicate<T> isNullPredicate(); @Override Integer apply(T t); @Override int applyAsInt(T t); @Override ToInt<T> orThrow(); @Override ToInt<T> orElseGet(ToInt<T> getter); @Override ToInt<T> orElse(Integer value); @Override ToDoubleNullable<T> mapToDoubleIfPresent(IntToDoubleFunction mapper); @Override ToIntNullable<T> mapIfPresent(IntUnaryOperator 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 testEquals() { final ToIntNullable<String> copy = instance; assertTrue(instance.equals(copy)); assertFalse(instance.equals(null)); final ToIntNullable<String> another = new ToIntNullableImpl<>( instance.inner(), instance.isNullPredicate() ); final ToIntNullable<String> originalSame = new ToIntNullableImpl<>( instance.inner(), Objects::isNull ); final ToIntNullable<String> isNullSame = new ToIntNullableImpl<>( String::length, instance.isNullPredicate() ); assertTrue(instance.equals(another)); assertFalse(instance.equals(originalSame)); assertFalse(instance.equals(isNullSame)); }