Fixed Java9 or newer issues.

This commit is contained in:
2022-12-15 17:13:34 +01:00
parent 9df95c0fc3
commit 859d00da16
6 changed files with 172 additions and 7 deletions
@@ -182,7 +182,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
* @return an array containing all of the elements in this collection
* @see Collection#toArray(Object[])
*/
default KEY_TYPE[] TO_ARRAY(IntFunction<KEY_TYPE[]> action) {
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
return TO_ARRAY(action.apply(size()));
}
@@ -288,12 +288,12 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
* @param action is the creator function of said Array to ensure type is kept.
* @return a new Array of all elements
*/
default KEY_TYPE[] TO_ARRAY(IntFunction<KEY_TYPE[]> action) {
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
ISizeProvider prov = ISizeProvider.of(this);
if(prov != null) {
int size = prov.size();
if(size >= 0) {
KEY_TYPE[] array = action.apply(size);
E[] array = action.apply(size);
ITERATORS.unwrap(array, iterator());
return array;
}
@@ -992,7 +992,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
#else
@Override
public T[] toArray(IntFunction<T[]> action) {
public <E> E[] toArray(IntFunction<E[]> action) {
return super.toArray(action);
}
@@ -188,7 +188,7 @@ public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TY
* @return an array containing all of the elements in this collection
* @see Collection#toArray(Object[])
*/
default KEY_TYPE[] TO_ARRAY(IntFunction<KEY_TYPE[]> action) {
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
return TO_ARRAY(action.apply(size()));
}
#endif
@@ -146,7 +146,7 @@ public class ARRAYS
* @param action that is creating the Array to be poured into
* @return array with all elements of the iterator
*/
public static GENERIC_KEY_BRACES KEY_TYPE[] pour(ITERATOR KEY_GENERIC_TYPE iter, IntFunction<KEY_TYPE[]> action) {
public static <T, E> E[] pour(ITERATOR KEY_GENERIC_TYPE iter, IntFunction<E[]> action) {
return pour(iter, Integer.MAX_VALUE, action);
}
@@ -158,7 +158,7 @@ public class ARRAYS
* @ArrayType(T)
* @return array with all requested elements of the iterator
*/
public static GENERIC_KEY_BRACES KEY_TYPE[] pour(ITERATOR KEY_GENERIC_TYPE iter, int max, IntFunction<KEY_TYPE[]> action) {
public static <T, E> E[] pour(ITERATOR KEY_GENERIC_TYPE iter, int max, IntFunction<E[]> action) {
COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE list = COLLECTIONS.wrapper();
ITERATORS.pour(iter, list, max);
return list.TO_ARRAY(action.apply(list.size()));