Project is now buildable.

-Moved: Code generation is in its own sourceset.
-Fixed: Bugs that caused that the project isnt buildable.
-Changed: Made build.gradle to a standard.
This commit is contained in:
2021-01-29 11:41:48 +01:00
parent 0cb07398f9
commit aaee550ea9
57 changed files with 132 additions and 86 deletions
@@ -0,0 +1,59 @@
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
* @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));
}
public default COMPARATOR reversed() {
return new Reversed(this);
}
static class Reversed implements COMPARATOR
{
COMPARATOR original;
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;
}
}
}
@@ -0,0 +1,59 @@
package speiger.src.collections.PACKAGE.functions;
import java.util.Objects;
import java.util.function.Consumer;
/**
* Type-Specific Consumer interface that reduces (un)boxing and allows to merge other consumer types into this interface
*/
@FunctionalInterface
#if JDK_TYPE && !TYPE_BOOLEAN
public interface CONSUMER extends Consumer<CLASS_TYPE>, JAVA_CONSUMER
#else
public interface CONSUMER extends Consumer<CLASS_TYPE>
#endif
{
/**
* Type-Specific function to reduce (un)boxing.
* Performs this operation on the given argument.
*
* @param t the input argument
*/
void accept(KEY_TYPE t);
public default CONSUMER andThen(CONSUMER after) {
Objects.requireNonNull(after);
return T -> {accept(T); after.accept(T);};
}
/** {@inheritDoc}
* <p>This default implementation delegates to the corresponding type-specific function.
* @deprecated Please use the corresponding type-specific function instead.
*/
@Override
@Deprecated
default void accept(CLASS_TYPE t) { accept(OBJ_TO_KEY(t)); }
/** {@inheritDoc}
* <p>This default implementation delegates to the corresponding type-specific function.
* @deprecated Please use the corresponding type-specific function instead.
*/
@Override
@Deprecated
default CONSUMER andThen(Consumer<? super CLASS_TYPE> after) {
Objects.requireNonNull(after);
return T -> {accept(T); after.accept(KEY_TO_OBJ(T));};
}
#if JDK_TYPE && PRIMITIVES
/** {@inheritDoc}
* <p>This default implementation delegates to the corresponding type-specific function.
* @deprecated Please use the corresponding type-specific function instead.
*/
@Override
@Deprecated
default CONSUMER andThen(JAVA_CONSUMER after) {
Objects.requireNonNull(after);
return T -> {accept(T); after.accept(T);};
}
#endif
}
@@ -0,0 +1,35 @@
package speiger.src.collections.PACKAGE.functions.consumer;
import java.util.Objects;
import java.util.function.BiConsumer;
public interface BI_CONSUMER KEY_VALUE_GENERIC_TYPE extends BiConsumer<CLASS_TYPE, CLASS_VALUE_TYPE>
{
void accept(KEY_TYPE k, VALUE_TYPE v);
public default BI_CONSUMER KEY_VALUE_GENERIC_TYPE andThen(BI_CONSUMER KEY_VALUE_GENERIC_TYPE after) {
Objects.requireNonNull(after);
return (K, V) -> {accept(K, V); after.accept(K, V);};
}
#if !TYPE_OBJECT || !VALUE_OBJECT
/** {@inheritDoc}
* <p>This default implementation delegates to the corresponding type-specific function.
* @deprecated Please use the corresponding type-specific function instead.
*/
@Override
@Deprecated
default void accept(CLASS_TYPE k, CLASS_VALUE_TYPE v) { accept(OBJ_TO_KEY(k), OBJ_TO_VALUE(v)); }
/** {@inheritDoc}
* <p>This default implementation delegates to the corresponding type-specific function.
* @deprecated Please use the corresponding type-specific function instead.
*/
@Override
@Deprecated
default BI_CONSUMER KEY_VALUE_GENERIC_TYPE andThen(BiConsumer<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE> after) {
Objects.requireNonNull(after);
return (K, V) -> {accept(K, V); after.accept(KEY_TO_OBJ(K), VALUE_TO_OBJ(V));};
}
#endif
}
@@ -0,0 +1,59 @@
package speiger.src.collections.PACKAGE.functions.function;
#if JDK_FUNCTION && VALUE_BOOLEAN
import java.util.Objects;
#endif
@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
{
public VALUE_TYPE GET_VALUE(KEY_TYPE k);
#if JDK_FUNCTION
#if VALUE_BOOLEAN
@Override
public default VALUE_TYPE test(KEY_TYPE k) { return GET_VALUE(k); }
public default FUNCTION KEY_VALUE_GENERIC_TYPE andType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
Objects.requireNonNull(other);
return T -> GET_VALUE(T) && other.GET_VALUE(T);
}
@Override
@Deprecated
public default FUNCTION KEY_VALUE_GENERIC_TYPE and(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
Objects.requireNonNull(other);
return T -> GET_VALUE(T) && other.test(T);
}
@Override
public default FUNCTION KEY_VALUE_GENERIC_TYPE negate() {
return T -> !GET_VALUE(T);
}
public default FUNCTION KEY_VALUE_GENERIC_TYPE orType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
Objects.requireNonNull(other);
return T -> GET_VALUE(T) || other.GET_VALUE(T);
}
@Override
@Deprecated
public default FUNCTION KEY_VALUE_GENERIC_TYPE or(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
Objects.requireNonNull(other);
return T -> GET_VALUE(T) || other.test(T);
}
#else if VALUE_OBJECT
@Override
public default VALUE_TYPE apply(KEY_TYPE k) { return GET_VALUE(k); }
#else
@Override
public default VALUE_TYPE APPLY_VALUE(KEY_TYPE k) { return GET_VALUE(k); }
#endif
#endif
}
@@ -0,0 +1,25 @@
package speiger.src.collections.PACKAGE.functions.function;
import java.util.function.BiFunction;
#if !SAME_TYPE || TYPE_BOOLEAN || !JDK_TYPE
public interface UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE extends BiFunction<CLASS_TYPE, CLASS_VALUE_TYPE, CLASS_VALUE_TYPE>
#else
#if SAME_TYPE && TYPE_OBJECT
public interface UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE extends BiFunction<CLASS_TYPE, CLASS_VALUE_TYPE, CLASS_VALUE_TYPE>
#else
public interface UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE extends BiFunction<CLASS_TYPE, CLASS_VALUE_TYPE, CLASS_VALUE_TYPE>, JAVA_BINARY_OPERATOR
#endif
#endif
{
#if TYPE_OBJECT && VALUE_OBJECT
#else if SAME_TYPE && !TYPE_OBJECT && JDK_TYPE && !TYPE_BOOLEAN
@Override
public default CLASS_VALUE_TYPE apply(CLASS_TYPE k, CLASS_VALUE_TYPE v) { return VALUE_TO_OBJ(APPLY_VALUE(OBJ_TO_KEY(k), OBJ_TO_VALUE(v))); }
#else
public VALUE_TYPE APPLY_VALUE(KEY_TYPE k, VALUE_TYPE v);
@Override
public default CLASS_VALUE_TYPE apply(CLASS_TYPE k, CLASS_VALUE_TYPE v) { return VALUE_TO_OBJ(APPLY_VALUE(OBJ_TO_KEY(k), OBJ_TO_VALUE(v))); }
#endif
}