ToDoubleNullableImpl implements NullableExpression<T, ToDouble<T>>, ToDoubleNullable<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()); } 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 testEquals() { final ToDoubleNullable<String> copy = instance; assertTrue(instance.equals(copy)); assertFalse(instance.equals(null)); final ToDoubleNullable<String> another = new ToDoubleNullableImpl<>( instance.inner(), instance.isNullPredicate() ); final ToDoubleNullable<String> originalSame = new ToDoubleNullableImpl<>( instance.inner(), Objects::isNull ); final ToDoubleNullable<String> isNullSame = new ToDoubleNullableImpl<>( String::length, instance.isNullPredicate() ); assertTrue(instance.equals(another)); assertFalse(instance.equals(originalSame)); assertFalse(instance.equals(isNullSame)); }