2020-11-12 02:13:54 +01:00
|
|
|
package speiger.src.collections.PACKAGE.functions;
|
2020-11-11 21:33:59 +01:00
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.function.Consumer;
|
2020-11-12 02:13:54 +01:00
|
|
|
#if !TYPE_BOOLEAN
|
|
|
|
#if !JDK_CONSUMER
|
|
|
|
import speiger.src.collections.utils.SanityChecks;
|
|
|
|
|
|
|
|
#endif
|
2020-11-11 21:33:59 +01:00
|
|
|
|
2020-12-06 09:32:22 +01:00
|
|
|
/**
|
|
|
|
* Type-Specific Consumer interface that reduces (un)boxing and allows to merge other consumer types into this interface
|
|
|
|
*/
|
2020-11-11 21:33:59 +01:00
|
|
|
public interface CONSUMER extends Consumer<CLASS_TYPE>, JAVA_CONSUMER
|
2020-11-12 02:13:54 +01:00
|
|
|
#else
|
|
|
|
|
2020-12-06 09:32:22 +01:00
|
|
|
/**
|
|
|
|
* Type-Specific Consumer interface that reduces (un)boxing and allows to merge other consumer types into this interface
|
|
|
|
*/
|
2020-11-12 02:13:54 +01:00
|
|
|
public interface CONSUMER extends Consumer<CLASS_TYPE>
|
|
|
|
#endif
|
|
|
|
{
|
2020-12-06 09:32:22 +01:00
|
|
|
/**
|
|
|
|
* Type-Specific method to reduce (un)boxing.
|
|
|
|
* Performs this operation on the given argument.
|
|
|
|
*
|
|
|
|
* @param t the input argument
|
|
|
|
*/
|
2020-11-11 21:33:59 +01:00
|
|
|
void accept(KEY_TYPE t);
|
|
|
|
|
2020-12-06 09:32:22 +01:00
|
|
|
#if !JDK_CONSUMER
|
|
|
|
/** {@inheritDoc}
|
|
|
|
* <p>This default implementation delegates to the corresponding type-specific method.
|
|
|
|
* @deprecated Please use the corresponding type-specific method instead.
|
|
|
|
*/
|
2020-11-12 02:13:54 +01:00
|
|
|
@Override
|
2020-12-06 09:32:22 +01:00
|
|
|
@Deprecated
|
2020-11-12 02:13:54 +01:00
|
|
|
default void accept(JAVA_TYPE t) { accept(SanityChecks.SANITY_CAST(t)); }
|
2020-12-06 09:32:22 +01:00
|
|
|
|
2020-11-12 02:13:54 +01:00
|
|
|
#endif
|
2020-12-06 09:32:22 +01:00
|
|
|
public default CONSUMER andThen(CONSUMER after) {
|
|
|
|
Objects.requireNonNull(after);
|
|
|
|
return T -> {accept(T); after.accept(T);};
|
|
|
|
}
|
2020-11-12 02:13:54 +01:00
|
|
|
|
2020-12-06 09:32:22 +01:00
|
|
|
/** {@inheritDoc}
|
|
|
|
* <p>This default implementation delegates to the corresponding type-specific method.
|
|
|
|
* @deprecated Please use the corresponding type-specific method instead.
|
|
|
|
*/
|
2020-11-12 02:13:54 +01:00
|
|
|
@Override
|
2020-12-06 09:32:22 +01:00
|
|
|
@Deprecated
|
2020-11-11 21:33:59 +01:00
|
|
|
default void accept(CLASS_TYPE t) { accept(OBJ_TO_KEY(t)); }
|
|
|
|
|
2020-12-06 09:32:22 +01:00
|
|
|
/** {@inheritDoc}
|
|
|
|
* <p>This default implementation delegates to the corresponding type-specific method.
|
|
|
|
* @deprecated Please use the corresponding type-specific method instead.
|
|
|
|
*/
|
2020-11-11 21:33:59 +01:00
|
|
|
@Override
|
2020-12-06 09:32:22 +01:00
|
|
|
@Deprecated
|
2020-11-11 21:33:59 +01:00
|
|
|
default CONSUMER andThen(Consumer<? super CLASS_TYPE> after) {
|
2020-11-12 02:13:54 +01:00
|
|
|
Objects.requireNonNull(after);
|
|
|
|
return T -> {accept(T); after.accept(KEY_TO_OBJ(T));};
|
|
|
|
}
|
|
|
|
|
2020-11-13 03:01:13 +01:00
|
|
|
#if PRIMITIVES
|
2020-12-06 09:32:22 +01:00
|
|
|
/** {@inheritDoc}
|
|
|
|
* <p>This default implementation delegates to the corresponding type-specific method.
|
|
|
|
* @deprecated Please use the corresponding type-specific method instead.
|
|
|
|
*/
|
2020-11-12 02:13:54 +01:00
|
|
|
@Override
|
2020-12-06 09:32:22 +01:00
|
|
|
@Deprecated
|
2020-11-12 02:13:54 +01:00
|
|
|
default CONSUMER andThen(JAVA_CONSUMER after) {
|
2020-11-11 21:33:59 +01:00
|
|
|
Objects.requireNonNull(after);
|
|
|
|
return T -> {accept(T); after.accept(T);};
|
|
|
|
}
|
2020-11-12 02:13:54 +01:00
|
|
|
#endif
|
2020-11-11 21:33:59 +01:00
|
|
|
}
|