net.adamcin.oakpal.core.Nothing Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of oakpal-core Show documentation
Show all versions of oakpal-core Show documentation
OakPAL Core Implementation
package net.adamcin.oakpal.core;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
/**
* A sentinel type for functional parameters representing Nothing, like Void.
*/
public final class Nothing {
/**
* This is the singleton sentinel value.
*/
public static final Nothing instance = new Nothing();
private Nothing() {
/* prevent instantiation */
}
@SuppressWarnings("WeakerAccess")
public static Function
voidToNothing1(final @NotNull Consumer super T> consumer) {
return input -> {
consumer.accept(input);
return Nothing.instance;
};
}
@SuppressWarnings("WeakerAccess")
public static BiFunction
voidToNothing2(final @NotNull BiConsumer super T, ? super U> consumer) {
return (inputT, inputU) -> {
consumer.accept(inputT, inputU);
return Nothing.instance;
};
}
@SuppressWarnings("WeakerAccess")
public Nothing combine(final @Nullable Nothing nothing) {
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy