Small Fixes to doc and Useless Imports
This commit is contained in:
+69
-69
@@ -1,70 +1,70 @@
|
||||
package speiger.src.collections.PACKAGE.functions;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Type-Specific Class for Comparator to reduce (un)boxing
|
||||
*/
|
||||
public interface COMPARATOR extends Comparator<CLASS_TYPE>
|
||||
{
|
||||
/**
|
||||
* Type-Specific compare function to reduce (un)boxing
|
||||
* @param o1 the first object to be compared.
|
||||
* @param o2 the second object to be compared.
|
||||
* @return a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
|
||||
* @see Comparator#compare(Object, Object)
|
||||
*/
|
||||
int compare(KEY_TYPE o1, KEY_TYPE o2);
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
default int compare(CLASS_TYPE o1, CLASS_TYPE o2) {
|
||||
return compare(OBJ_TO_KEY(o1), OBJ_TO_KEY(o2));
|
||||
}
|
||||
|
||||
/**
|
||||
* A Wrapper function to convert a Non-Type-Specific Comparator to a Type-Specific-Comparator
|
||||
* @param c comparator to convert
|
||||
* @return the wrapper of the comparator
|
||||
* @throws NullPointerException if the comparator is null
|
||||
*/
|
||||
public static COMPARATOR of(Comparator<CLASS_TYPE> c) {
|
||||
Objects.requireNonNull(c);
|
||||
return (K, V) -> c.compare(KEY_TO_OBJ(K), KEY_TO_OBJ(V));
|
||||
}
|
||||
|
||||
@Override
|
||||
public default COMPARATOR reversed() {
|
||||
return new Reversed(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type Specific Reversed Comparator to reduce boxing/unboxing
|
||||
*/
|
||||
static class Reversed implements COMPARATOR
|
||||
{
|
||||
COMPARATOR original;
|
||||
|
||||
/**
|
||||
* default constructor
|
||||
* @param original that is going to be reversed
|
||||
*/
|
||||
public Reversed(COMPARATOR original) {
|
||||
this.original = original;
|
||||
}
|
||||
|
||||
public int compare(KEY_TYPE o1, KEY_TYPE o2) {
|
||||
return original.compare(o2, o1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public COMPARATOR reversed() {
|
||||
return original;
|
||||
}
|
||||
}
|
||||
package speiger.src.collections.PACKAGE.functions;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Type-Specific Class for Comparator to reduce (un)boxing
|
||||
*/
|
||||
public interface COMPARATOR extends Comparator<CLASS_TYPE>
|
||||
{
|
||||
/**
|
||||
* Type-Specific compare function to reduce (un)boxing
|
||||
* @param o1 the first object to be compared.
|
||||
* @param o2 the second object to be compared.
|
||||
* @return a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
|
||||
* @see Comparator#compare(Object, Object)
|
||||
*/
|
||||
int compare(KEY_TYPE o1, KEY_TYPE o2);
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
default int compare(CLASS_TYPE o1, CLASS_TYPE o2) {
|
||||
return compare(OBJ_TO_KEY(o1), OBJ_TO_KEY(o2));
|
||||
}
|
||||
|
||||
/**
|
||||
* A Wrapper function to convert a Non-Type-Specific Comparator to a Type-Specific-Comparator
|
||||
* @param c comparator to convert
|
||||
* @return the wrapper of the comparator
|
||||
* @throws NullPointerException if the comparator is null
|
||||
*/
|
||||
public static COMPARATOR of(Comparator<CLASS_TYPE> c) {
|
||||
Objects.requireNonNull(c);
|
||||
return (K, V) -> c.compare(KEY_TO_OBJ(K), KEY_TO_OBJ(V));
|
||||
}
|
||||
|
||||
@Override
|
||||
public default COMPARATOR reversed() {
|
||||
return new Reversed(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type Specific Reversed Comparator to reduce boxing/unboxing
|
||||
*/
|
||||
static class Reversed implements COMPARATOR
|
||||
{
|
||||
COMPARATOR original;
|
||||
|
||||
/**
|
||||
* default constructor
|
||||
* @param original that is going to be reversed
|
||||
*/
|
||||
public Reversed(COMPARATOR original) {
|
||||
this.original = original;
|
||||
}
|
||||
|
||||
public int compare(KEY_TYPE o1, KEY_TYPE o2) {
|
||||
return original.compare(o2, o1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public COMPARATOR reversed() {
|
||||
return original;
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
-18
@@ -1,19 +1,19 @@
|
||||
package speiger.src.collections.PACKAGE.functions;
|
||||
|
||||
/**
|
||||
* Type-Specific Supplier interface that reduces (un)boxing and allows to merge other consumer types into this interface
|
||||
* @Type(T)
|
||||
*/
|
||||
#if TYPE_OBJECT
|
||||
public interface SUPPLIER KEY_GENERIC_TYPE extends java.util.function.Supplier<KEY_TYPE>
|
||||
#else if JDK_TYPE && !TYPE_BOOLEAN
|
||||
public interface SUPPLIER KEY_GENERIC_TYPE extends JAVA_SUPPLIER
|
||||
#else
|
||||
public interface SUPPLIER KEY_GENERIC_TYPE
|
||||
#endif
|
||||
{
|
||||
/**
|
||||
* @return the supplied value
|
||||
*/
|
||||
public KEY_TYPE SUPPLY_GET();
|
||||
package speiger.src.collections.PACKAGE.functions;
|
||||
|
||||
/**
|
||||
* Type-Specific Supplier interface that reduces (un)boxing and allows to merge other consumer types into this interface
|
||||
* @Type(T)
|
||||
*/
|
||||
#if TYPE_OBJECT
|
||||
public interface SUPPLIER KEY_GENERIC_TYPE extends java.util.function.Supplier<KEY_TYPE>
|
||||
#else if JDK_TYPE && !TYPE_BOOLEAN
|
||||
public interface SUPPLIER KEY_GENERIC_TYPE extends JAVA_SUPPLIER
|
||||
#else
|
||||
public interface SUPPLIER KEY_GENERIC_TYPE
|
||||
#endif
|
||||
{
|
||||
/**
|
||||
* @return the supplied value
|
||||
*/
|
||||
public KEY_TYPE SUPPLY_GET();
|
||||
}
|
||||
+91
-91
@@ -1,92 +1,92 @@
|
||||
package speiger.src.collections.PACKAGE.functions;
|
||||
|
||||
import java.util.concurrent.RunnableFuture;
|
||||
#if !TYPE_OBJECT
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
* A Type Specific Task interface that allows you to keep track of the task that is currently running.<br>
|
||||
* It extends Runnable future and supports said functions but also provides quality of life functions like:<br>
|
||||
*
|
||||
* - isSuccesfull: which allows to detect if the task was completed properly and not interrupted or crashed.
|
||||
* - pause/resume: which allows to pause/resume the task at any moment, making it easier to create thread-safe actions.
|
||||
* @Type(T)
|
||||
*/
|
||||
public interface TASK KEY_GENERIC_TYPE extends RunnableFuture<CLASS_TYPE> {
|
||||
/**
|
||||
* Helper function to detect if the task is currently paused.
|
||||
* @return true if paused
|
||||
*/
|
||||
public boolean isPaused();
|
||||
|
||||
/**
|
||||
* Pauses the task, which lets the thread finish without completing the task.
|
||||
* Tasks are written in the way where they can pause without any issues.
|
||||
* This won't be instant, as this function is applied asynchronous and doesn't check if the thread paused.
|
||||
* So make sure it had the time to pause.
|
||||
*/
|
||||
public void pause();
|
||||
|
||||
/**
|
||||
* Pauses the task, which lets the thread finish without completing the task.
|
||||
* Tasks are written in the way where they can pause without any issues.
|
||||
* This won't be instant, as this function is applied asynchronous.
|
||||
* It will await the pausing of the task.
|
||||
*/
|
||||
public void awaitPausing();
|
||||
|
||||
/**
|
||||
* Continues the task if it wasn't already completed.
|
||||
* This is done by resubmitting the task to the executor provided.
|
||||
*/
|
||||
public void resume();
|
||||
|
||||
/**
|
||||
* Quality of life function that allows to detect if no cancellation/exception was applied to this task and it completed on its own.
|
||||
* @return true if it was properly completed
|
||||
*/
|
||||
public boolean isSuccessful();
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type Specific get method that allows to reduce (un)boxing of primtives.
|
||||
*
|
||||
* Waits if necessary for the computation to complete, and then
|
||||
* retrieves its result.
|
||||
*
|
||||
* @return the computed result as primitive
|
||||
* @throws CancellationException if the computation was cancelled
|
||||
* @throws ExecutionException if the computation threw an exception
|
||||
* @throws InterruptedException if the current thread was interrupted
|
||||
* while waiting
|
||||
*/
|
||||
public KEY_TYPE GET_KEY() throws InterruptedException, ExecutionException;
|
||||
|
||||
/**
|
||||
* Waits if necessary for at most the given time for the computation
|
||||
* to complete, and then retrieves its result, if available.
|
||||
*
|
||||
* @param timeout the maximum time to wait
|
||||
* @param unit the time unit of the timeout argument
|
||||
* @return the computed result as primitive
|
||||
* @throws CancellationException if the computation was cancelled
|
||||
* @throws ExecutionException if the computation threw an exception
|
||||
* @throws InterruptedException if the current thread was interrupted while waiting
|
||||
* @throws TimeoutException if the wait timed out
|
||||
*/
|
||||
public KEY_TYPE GET_KEY(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException;
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default CLASS_TYPE get() throws InterruptedException, ExecutionException { return KEY_TO_OBJ(GET_KEY()); }
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default CLASS_TYPE get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return KEY_TO_OBJ(GET_KEY(timeout, unit)); }
|
||||
#endif
|
||||
package speiger.src.collections.PACKAGE.functions;
|
||||
|
||||
import java.util.concurrent.RunnableFuture;
|
||||
#if !TYPE_OBJECT
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
* A Type Specific Task interface that allows you to keep track of the task that is currently running.<br>
|
||||
* It extends Runnable future and supports said functions but also provides quality of life functions like:<br>
|
||||
*
|
||||
* - isSuccesfull: which allows to detect if the task was completed properly and not interrupted or crashed.
|
||||
* - pause/resume: which allows to pause/resume the task at any moment, making it easier to create thread-safe actions.
|
||||
* @Type(T)
|
||||
*/
|
||||
public interface TASK KEY_GENERIC_TYPE extends RunnableFuture<CLASS_TYPE> {
|
||||
/**
|
||||
* Helper function to detect if the task is currently paused.
|
||||
* @return true if paused
|
||||
*/
|
||||
public boolean isPaused();
|
||||
|
||||
/**
|
||||
* Pauses the task, which lets the thread finish without completing the task.
|
||||
* Tasks are written in the way where they can pause without any issues.
|
||||
* This won't be instant, as this function is applied asynchronous and doesn't check if the thread paused.
|
||||
* So make sure it had the time to pause.
|
||||
*/
|
||||
public void pause();
|
||||
|
||||
/**
|
||||
* Pauses the task, which lets the thread finish without completing the task.
|
||||
* Tasks are written in the way where they can pause without any issues.
|
||||
* This won't be instant, as this function is applied asynchronous.
|
||||
* It will await the pausing of the task.
|
||||
*/
|
||||
public void awaitPausing();
|
||||
|
||||
/**
|
||||
* Continues the task if it wasn't already completed.
|
||||
* This is done by resubmitting the task to the executor provided.
|
||||
*/
|
||||
public void resume();
|
||||
|
||||
/**
|
||||
* Quality of life function that allows to detect if no cancellation/exception was applied to this task and it completed on its own.
|
||||
* @return true if it was properly completed
|
||||
*/
|
||||
public boolean isSuccessful();
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
/**
|
||||
* A Type Specific get method that allows to reduce (un)boxing of primtives.
|
||||
*
|
||||
* Waits if necessary for the computation to complete, and then
|
||||
* retrieves its result.
|
||||
*
|
||||
* @return the computed result as primitive
|
||||
* @throws CancellationException if the computation was cancelled
|
||||
* @throws ExecutionException if the computation threw an exception
|
||||
* @throws InterruptedException if the current thread was interrupted
|
||||
* while waiting
|
||||
*/
|
||||
public KEY_TYPE GET_KEY() throws InterruptedException, ExecutionException;
|
||||
|
||||
/**
|
||||
* Waits if necessary for at most the given time for the computation
|
||||
* to complete, and then retrieves its result, if available.
|
||||
*
|
||||
* @param timeout the maximum time to wait
|
||||
* @param unit the time unit of the timeout argument
|
||||
* @return the computed result as primitive
|
||||
* @throws CancellationException if the computation was cancelled
|
||||
* @throws ExecutionException if the computation threw an exception
|
||||
* @throws InterruptedException if the current thread was interrupted while waiting
|
||||
* @throws TimeoutException if the wait timed out
|
||||
*/
|
||||
public KEY_TYPE GET_KEY(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException;
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default CLASS_TYPE get() throws InterruptedException, ExecutionException { return KEY_TO_OBJ(GET_KEY()); }
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default CLASS_TYPE get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return KEY_TO_OBJ(GET_KEY(timeout, unit)); }
|
||||
#endif
|
||||
}
|
||||
+133
-133
@@ -1,134 +1,134 @@
|
||||
package speiger.src.collections.PACKAGE.functions.function;
|
||||
|
||||
#if VALUE_BOOLEAN || SAME_TYPE
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
*/
|
||||
@FunctionalInterface
|
||||
#if JDK_FUNCTION
|
||||
public interface FUNCTION KEY_VALUE_GENERIC_TYPE extends JAVA_FUNCTION KEY_VALUE_GENERIC_TYPE
|
||||
#else
|
||||
public interface FUNCTION KEY_VALUE_GENERIC_TYPE
|
||||
#endif
|
||||
{
|
||||
/**
|
||||
* Type Specific get function to reduce boxing/unboxing
|
||||
* @param k the value that should be processed
|
||||
* @return the result of the function
|
||||
*/
|
||||
public VALUE_TYPE APPLY(KEY_TYPE k);
|
||||
|
||||
#if SAME_TYPE
|
||||
/**
|
||||
* Creates a Default function that returns the input provided.
|
||||
* @Type(T)
|
||||
* @return a input returning function
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES FUNCTION KEY_SAME_GENERIC_TYPE identity() {
|
||||
return T -> T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a composed function that first applies the {@code before}
|
||||
* function to its input, and then applies this function to the result.
|
||||
* If evaluation of either function throws an exception, it is relayed to
|
||||
* the caller of the composed function.
|
||||
*
|
||||
* @Type(I)
|
||||
* @param before the function that should be used first
|
||||
* @return a composed function with a different starting function.
|
||||
*/
|
||||
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION SV_GENERIC_TYPE<I> compose(FUNCTION SK_GENERIC_TYPE<I> before) {
|
||||
Objects.requireNonNull(before);
|
||||
return T -> APPLY(before.APPLY(T));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a composed function that first applies this function to
|
||||
* its input, and then applies the {@code after} function to the result.
|
||||
* If evaluation of either function throws an exception, it is relayed to
|
||||
* the caller of the composed function.
|
||||
*
|
||||
* @Type(I)
|
||||
* @param after the function that should be used last
|
||||
* @return a composed function with a different starting function.
|
||||
*/
|
||||
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION KS_GENERIC_TYPE<I> andThen(FUNCTION VS_GENERIC_TYPE<I> after) {
|
||||
Objects.requireNonNull(after);
|
||||
return T -> after.APPLY(APPLY(T));
|
||||
}
|
||||
|
||||
#endif
|
||||
#if VALUE_BOOLEAN
|
||||
/**
|
||||
* Creates a Always true function that may be useful if you don't need to process information or just want a default.
|
||||
* @Type(T)
|
||||
* @return a default returning function
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysTrue() {
|
||||
return T -> true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Always false function that may be useful if you don't need to process information or just want a default.
|
||||
* @Type(T)
|
||||
* @return a default returning function
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysFalse() {
|
||||
return T -> false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type specific and-function helper function that reduces boxing/unboxing
|
||||
* @param other the other function that should be merged with.
|
||||
* @return a function that compares values in a and comparason
|
||||
*/
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE andType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) && other.APPLY(T);
|
||||
}
|
||||
|
||||
#if JDK_FUNCTION
|
||||
@Override
|
||||
@Deprecated
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE and(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) && other.APPLY(T);
|
||||
}
|
||||
|
||||
@Override
|
||||
#else
|
||||
/**
|
||||
* A type specific inverter function
|
||||
* @return the same function but inverts the result
|
||||
*/
|
||||
#endif
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE negate() {
|
||||
return T -> !APPLY(T);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type specific or-function helper function that reduces boxing/unboxing
|
||||
* @param other the other function that should be merged with.
|
||||
* @return a function that compares values in a or comparason
|
||||
*/
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE orType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) || other.APPLY(T);
|
||||
}
|
||||
|
||||
#if JDK_FUNCTION
|
||||
@Override
|
||||
@Deprecated
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE or(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) || other.APPLY(T);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
package speiger.src.collections.PACKAGE.functions.function;
|
||||
|
||||
#if VALUE_BOOLEAN || SAME_TYPE
|
||||
import java.util.Objects;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
||||
* @Type(T)
|
||||
* @ValueType(V)
|
||||
*/
|
||||
@FunctionalInterface
|
||||
#if JDK_FUNCTION
|
||||
public interface FUNCTION KEY_VALUE_GENERIC_TYPE extends JAVA_FUNCTION KEY_VALUE_GENERIC_TYPE
|
||||
#else
|
||||
public interface FUNCTION KEY_VALUE_GENERIC_TYPE
|
||||
#endif
|
||||
{
|
||||
/**
|
||||
* Type Specific get function to reduce boxing/unboxing
|
||||
* @param k the value that should be processed
|
||||
* @return the result of the function
|
||||
*/
|
||||
public VALUE_TYPE APPLY(KEY_TYPE k);
|
||||
|
||||
#if SAME_TYPE
|
||||
/**
|
||||
* Creates a Default function that returns the input provided.
|
||||
* @Type(T)
|
||||
* @return a input returning function
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES FUNCTION KEY_SAME_GENERIC_TYPE identity() {
|
||||
return T -> T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a composed function that first applies the {@code before}
|
||||
* function to its input, and then applies this function to the result.
|
||||
* If evaluation of either function throws an exception, it is relayed to
|
||||
* the caller of the composed function.
|
||||
*
|
||||
* @Type(I)
|
||||
* @param before the function that should be used first
|
||||
* @return a composed function with a different starting function.
|
||||
*/
|
||||
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION SV_GENERIC_TYPE<I> compose(FUNCTION SK_GENERIC_TYPE<I> before) {
|
||||
Objects.requireNonNull(before);
|
||||
return T -> APPLY(before.APPLY(T));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a composed function that first applies this function to
|
||||
* its input, and then applies the {@code after} function to the result.
|
||||
* If evaluation of either function throws an exception, it is relayed to
|
||||
* the caller of the composed function.
|
||||
*
|
||||
* @Type(I)
|
||||
* @param after the function that should be used last
|
||||
* @return a composed function with a different starting function.
|
||||
*/
|
||||
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION KS_GENERIC_TYPE<I> andThen(FUNCTION VS_GENERIC_TYPE<I> after) {
|
||||
Objects.requireNonNull(after);
|
||||
return T -> after.APPLY(APPLY(T));
|
||||
}
|
||||
|
||||
#endif
|
||||
#if VALUE_BOOLEAN
|
||||
/**
|
||||
* Creates a Always true function that may be useful if you don't need to process information or just want a default.
|
||||
* @Type(T)
|
||||
* @return a default returning function
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysTrue() {
|
||||
return T -> true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Always false function that may be useful if you don't need to process information or just want a default.
|
||||
* @Type(T)
|
||||
* @return a default returning function
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysFalse() {
|
||||
return T -> false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type specific and-function helper function that reduces boxing/unboxing
|
||||
* @param other the other function that should be merged with.
|
||||
* @return a function that compares values in a and comparason
|
||||
*/
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE andType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) && other.APPLY(T);
|
||||
}
|
||||
|
||||
#if JDK_FUNCTION
|
||||
@Override
|
||||
@Deprecated
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE and(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) && other.APPLY(T);
|
||||
}
|
||||
|
||||
@Override
|
||||
#else
|
||||
/**
|
||||
* A type specific inverter function
|
||||
* @return the same function but inverts the result
|
||||
*/
|
||||
#endif
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE negate() {
|
||||
return T -> !APPLY(T);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Type specific or-function helper function that reduces boxing/unboxing
|
||||
* @param other the other function that should be merged with.
|
||||
* @return a function that compares values in a or comparason
|
||||
*/
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE orType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) || other.APPLY(T);
|
||||
}
|
||||
|
||||
#if JDK_FUNCTION
|
||||
@Override
|
||||
@Deprecated
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE or(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> APPLY(T) || other.APPLY(T);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user