From c8e5c16e413816018b0c0325dd81646787077470 Mon Sep 17 00:00:00 2001 From: Sen Date: Fri, 30 May 2025 13:00:33 +0200 Subject: [PATCH] fix gradle compile errors --- common/src/main/java/common/block/Block.java | 2 +- .../src/main/java/common/collect/Filter.java | 4 +- .../main/java/common/collect/Iterables.java | 98 ------- .../main/java/common/collect/Iterators.java | 258 ------------------ 4 files changed, 3 insertions(+), 359 deletions(-) diff --git a/common/src/main/java/common/block/Block.java b/common/src/main/java/common/block/Block.java index d25e4d7..33ee066 100755 --- a/common/src/main/java/common/block/Block.java +++ b/common/src/main/java/common/block/Block.java @@ -62,7 +62,7 @@ public class Block { } public Iterator iterator() { - return (Iterator)(this.iterables.length <= 0 ? Collections.singletonList((Object[])createArray(this.clazz, 0)).iterator() + return (Iterator)(this.iterables.length <= 0 ? Collections.singletonList((T[])createArray(this.clazz, 0)).iterator() : new Product.ProductIterator(this.clazz, this.iterables)); } diff --git a/common/src/main/java/common/collect/Filter.java b/common/src/main/java/common/collect/Filter.java index a9f4fd1..c403295 100644 --- a/common/src/main/java/common/collect/Filter.java +++ b/common/src/main/java/common/collect/Filter.java @@ -183,12 +183,12 @@ public final class Filter { @Override public boolean removeAll(final Collection collection) { - return Iterables.removeIf(unfiltered, and(predicate, in(collection))); + return Iterables.removeIf(unfiltered, and(predicate, in((Collection)collection))); } @Override public boolean retainAll(final Collection collection) { - return Iterables.removeIf(unfiltered, and(predicate, not(in(collection)))); + return Iterables.removeIf(unfiltered, and(predicate, not(in((Collection)collection)))); } @Override diff --git a/common/src/main/java/common/collect/Iterables.java b/common/src/main/java/common/collect/Iterables.java index 4a71710..06dce11 100644 --- a/common/src/main/java/common/collect/Iterables.java +++ b/common/src/main/java/common/collect/Iterables.java @@ -45,104 +45,6 @@ import java.util.function.Predicate; public final class Iterables { private Iterables() {} - /** Returns an unmodifiable view of {@code iterable}. */ -// public static Iterable unmodifiableIterable( -// final Iterable iterable) { -// checkNotNull(iterable); -// if (iterable instanceof UnmodifiableIterable || -// iterable instanceof ImmutableCollection) { -// return iterable; -// } -// return new UnmodifiableIterable(iterable); -// } - - /** - * Simply returns its argument. - * - * @deprecated no need to use this - * @since 10.0 - */ -// @Deprecated public static Iterable unmodifiableIterable( -// ImmutableCollection iterable) { -// return checkNotNull(iterable); -// } - -// private static final class UnmodifiableIterable extends FluentIterable { -// private final Iterable iterable; -// -// private UnmodifiableIterable(Iterable iterable) { -// this.iterable = iterable; -// } -// -// @Override -// public Iterator iterator() { -// return Iterators.unmodifiableIterator(iterable.iterator()); -// } -// -// @Override -// public String toString() { -// return iterable.toString(); -// } -// // no equals and hashCode; it would break the contract! -// } - - /** - * Returns the number of elements in {@code iterable}. - */ -// public static int size(Iterable iterable) { -// return (iterable instanceof Collection) -// ? ((Collection) iterable).size() -// : Iterators.size(iterable.iterator()); -// } - - /** - * Returns {@code true} if {@code iterable} contains any object for which {@code equals(element)} - * is true. - */ -// public static boolean contains(Iterable iterable, Object element) { -// if (iterable instanceof Collection) { -// Collection collection = (Collection) iterable; -// return Filter.safeContains(collection, element); -// } -// return Iterators.contains(iterable.iterator(), element); -// } - - /** - * Removes, from an iterable, every element that belongs to the provided - * collection. - * - *

This method calls {@link Collection#removeAll} if {@code iterable} is a - * collection, and {@link Iterators#removeAll} otherwise. - * - * @param removeFrom the iterable to (potentially) remove elements from - * @param elementsToRemove the elements to remove - * @return {@code true} if any element was removed from {@code iterable} - */ -// public static boolean removeAll( -// Iterable removeFrom, Collection elementsToRemove) { -// return (removeFrom instanceof Collection) -// ? ((Collection) removeFrom).removeAll(checkNotNull(elementsToRemove)) -// : Iterators.removeAll(removeFrom.iterator(), elementsToRemove); -// } - - /** - * Removes, from an iterable, every element that does not belong to the - * provided collection. - * - *

This method calls {@link Collection#retainAll} if {@code iterable} is a - * collection, and {@link Iterators#retainAll} otherwise. - * - * @param removeFrom the iterable to (potentially) remove elements from - * @param elementsToRetain the elements to retain - * @return {@code true} if any element was removed from {@code iterable} - */ -// public static boolean retainAll( -// Iterable removeFrom, Collection elementsToRetain) { -// return (removeFrom instanceof Collection) -// ? ((Collection) removeFrom).retainAll(checkNotNull(elementsToRetain)) -// : Iterators.retainAll(removeFrom.iterator(), elementsToRetain); -// } - /** * Removes, from an iterable, every element that satisfies the provided * predicate. diff --git a/common/src/main/java/common/collect/Iterators.java b/common/src/main/java/common/collect/Iterators.java index 350c9ef..c92d91c 100644 --- a/common/src/main/java/common/collect/Iterators.java +++ b/common/src/main/java/common/collect/Iterators.java @@ -148,17 +148,6 @@ public final class Iterators { }; } - /** - * Simply returns its argument. - * - * @deprecated no need to use this - * @since 10.0 - */ -// @Deprecated public static UnmodifiableIterator unmodifiableIterator( -// UnmodifiableIterator iterator) { -// return checkNotNull(iterator); -// } - /** * Returns the number of elements remaining in {@code iterator}. The iterator * will be left exhausted: its {@code hasNext()} method will return @@ -1040,253 +1029,6 @@ public final class Iterators { }; } - /** - * Returns an iterator containing only {@code value}. - * - *

The {@link Iterable} equivalent of this method is {@link - * Collections#singleton}. - */ -// public static UnmodifiableIterator singletonIterator( -// final T value) { -// return new UnmodifiableIterator() { -// boolean done; -// @Override -// public boolean hasNext() { -// return !done; -// } -// @Override -// public T next() { -// if (done) { -// throw new NoSuchElementException(); -// } -// done = true; -// return value; -// } -// }; -// } - - /** - * Adapts an {@code Enumeration} to the {@code Iterator} interface. - * - *

This method has no equivalent in {@link Iterables} because viewing an - * {@code Enumeration} as an {@code Iterable} is impossible. However, the - * contents can be copied into a collection using {@link - * Collections#list}. - */ -// public static UnmodifiableIterator forEnumeration( -// final Enumeration enumeration) { -// checkNotNull(enumeration); -// return new UnmodifiableIterator() { -// @Override -// public boolean hasNext() { -// return enumeration.hasMoreElements(); -// } -// @Override -// public T next() { -// return enumeration.nextElement(); -// } -// }; -// } - - /** - * Adapts an {@code Iterator} to the {@code Enumeration} interface. - * - *

The {@code Iterable} equivalent of this method is either {@link - * Collections#enumeration} (if you have a {@link Collection}), or - * {@code Iterators.asEnumeration(collection.iterator())}. - */ -// public static Enumeration asEnumeration(final Iterator iterator) { -// checkNotNull(iterator); -// return new Enumeration() { -// @Override -// public boolean hasMoreElements() { -// return iterator.hasNext(); -// } -// @Override -// public T nextElement() { -// return iterator.next(); -// } -// }; -// } - - /** - * Implementation of PeekingIterator that avoids peeking unless necessary. - */ -// private static class PeekingImpl implements PeekingIterator { -// -// private final Iterator iterator; -// private boolean hasPeeked; -// private E peekedElement; -// -// public PeekingImpl(Iterator iterator) { -// this.iterator = checkNotNull(iterator); -// } -// -// @Override -// public boolean hasNext() { -// return hasPeeked || iterator.hasNext(); -// } -// -// @Override -// public E next() { -// if (!hasPeeked) { -// return iterator.next(); -// } -// E result = peekedElement; -// hasPeeked = false; -// peekedElement = null; -// return result; -// } -// -// @Override -// public void remove() { -// checkState(!hasPeeked, "Can't remove after you've peeked at next"); -// iterator.remove(); -// } -// -// @Override -// public E peek() { -// if (!hasPeeked) { -// peekedElement = iterator.next(); -// hasPeeked = true; -// } -// return peekedElement; -// } -// } - - /** - * Returns a {@code PeekingIterator} backed by the given iterator. - * - *

Calls to the {@code peek} method with no intervening calls to {@code - * next} do not affect the iteration, and hence return the same object each - * time. A subsequent call to {@code next} is guaranteed to return the same - * object again. For example:

   {@code
-   *
-   *   PeekingIterator peekingIterator =
-   *       Iterators.peekingIterator(Iterators.forArray("a", "b"));
-   *   String a1 = peekingIterator.peek(); // returns "a"
-   *   String a2 = peekingIterator.peek(); // also returns "a"
-   *   String a3 = peekingIterator.next(); // also returns "a"}
- * - *

Any structural changes to the underlying iteration (aside from those - * performed by the iterator's own {@link PeekingIterator#remove()} method) - * will leave the iterator in an undefined state. - * - *

The returned iterator does not support removal after peeking, as - * explained by {@link PeekingIterator#remove()}. - * - *

Note: If the given iterator is already a {@code PeekingIterator}, - * it might be returned to the caller, although this is neither - * guaranteed to occur nor required to be consistent. For example, this - * method might choose to pass through recognized implementations of - * {@code PeekingIterator} when the behavior of the implementation is - * known to meet the contract guaranteed by this method. - * - *

There is no {@link Iterable} equivalent to this method, so use this - * method to wrap each individual iterator as it is generated. - * - * @param iterator the backing iterator. The {@link PeekingIterator} assumes - * ownership of this iterator, so users should cease making direct calls - * to it after calling this method. - * @return a peeking iterator backed by that iterator. Apart from the - * additional {@link PeekingIterator#peek()} method, this iterator behaves - * exactly the same as {@code iterator}. - */ -// public static PeekingIterator peekingIterator( -// Iterator iterator) { -// if (iterator instanceof PeekingImpl) { -// // Safe to cast to because PeekingImpl only uses T -// // covariantly (and cannot be subclassed to add non-covariant uses). -// -// PeekingImpl peeking = (PeekingImpl) iterator; -// return peeking; -// } -// return new PeekingImpl(iterator); -// } - - /** - * Simply returns its argument. - * - * @deprecated no need to use this - * @since 10.0 - */ -// @Deprecated public static PeekingIterator peekingIterator( -// PeekingIterator iterator) { -// return checkNotNull(iterator); -// } - - /** - * Returns an iterator over the merged contents of all given - * {@code iterators}, traversing every element of the input iterators. - * Equivalent entries will not be de-duplicated. - * - *

Callers must ensure that the source {@code iterators} are in - * non-descending order as this method does not sort its input. - * - *

For any equivalent elements across all {@code iterators}, it is - * undefined which element is returned first. - * - * @since 11.0 - */ -// @Beta -// public static UnmodifiableIterator mergeSorted( -// Iterable> iterators, -// Comparator comparator) { -// checkNotNull(iterators, "iterators"); -// checkNotNull(comparator, "comparator"); -// -// return new MergingIterator(iterators, comparator); -// } - - /** - * An iterator that performs a lazy N-way merge, calculating the next value - * each time the iterator is polled. This amortizes the sorting cost over the - * iteration and requires less memory than sorting all elements at once. - * - *

Retrieving a single element takes approximately O(log(M)) time, where M - * is the number of iterators. (Retrieving all elements takes approximately - * O(N*log(M)) time, where N is the total number of elements.) - */ -// private static class MergingIterator extends UnmodifiableIterator { -// final Queue> queue; -// -// public MergingIterator(Iterable> iterators, -// final Comparator itemComparator) { -// // A comparator that's used by the heap, allowing the heap -// // to be sorted based on the top of each iterator. -// Comparator> heapComparator = -// new Comparator>() { -// @Override -// public int compare(PeekingIterator o1, PeekingIterator o2) { -// return itemComparator.compare(o1.peek(), o2.peek()); -// } -// }; -// -// queue = new PriorityQueue>(2, heapComparator); -// -// for (Iterator iterator : iterators) { -// if (iterator.hasNext()) { -// queue.add(Iterators.peekingIterator(iterator)); -// } -// } -// } -// -// @Override -// public boolean hasNext() { -// return !queue.isEmpty(); -// } -// -// @Override -// public T next() { -// PeekingIterator nextIter = queue.remove(); -// T next = nextIter.next(); -// if (nextIter.hasNext()) { -// queue.add(nextIter); -// } -// return next; -// } -// } - /** * Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */