diff --git a/forge-core/src/main/java/forge/util/Iterables.java b/forge-core/src/main/java/forge/util/Iterables.java index a0d1e9b9911..22328230401 100644 --- a/forge-core/src/main/java/forge/util/Iterables.java +++ b/forge-core/src/main/java/forge/util/Iterables.java @@ -1,7 +1,6 @@ package forge.util; import java.util.Collection; -import java.util.List; import java.util.Optional; import java.util.function.Function; import java.util.function.Predicate; @@ -59,33 +58,10 @@ public class Iterables { } public static Iterable transform(final Iterable iterable, final Function function) { - //TODO: Collection input variant. Some usages use Lists.newArrayList on output which could be made part of the stream. //Should probably also be ? extends T in the function type return () -> StreamSupport.stream(iterable.spliterator(), false).map(function).iterator(); } - //TODO: Inline everything below. - - - public static int size(Collection collection) { - return collection.size(); - } - - public static boolean contains(Collection collection, Object element) { - return collection.contains(element); - } - - public static T getFirst(List iterable, T defaultValue) { - return iterable.isEmpty() ? defaultValue : iterable.get(0); - } - - public static T getLast(List iterable) { - return iterable.get(iterable.size() - 1); - } - public static T getLast(List iterable, T defaultValue) { - return iterable.isEmpty() ? defaultValue : iterable.get(iterable.size() - 1); - } - //TODO: Restore everything below public static Iterable unmodifiableIterable(final Iterable iterable) { return com.google.common.collect.Iterables.unmodifiableIterable(iterable); diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java index 7a72efbf537..116a5670f8e 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestUtilUnlockSets.java @@ -35,6 +35,7 @@ import forge.util.storage.IStorage; import org.apache.commons.lang3.tuple.ImmutablePair; import java.util.*; +import java.util.stream.Collectors; /** * This is a helper class for unlocking new sets during a format-limited @@ -136,14 +137,17 @@ public class QuestUtilUnlockSets { throw new RuntimeException("BUG? Could not find unlockable sets even though we should."); } List options = new ArrayList<>(); + CardEdition.Collection editions = FModel.getMagicDb().getEditions(); // Sort current sets by date - List allowedSets = Lists.newArrayList(Iterables.transform(qData.getFormat().getAllowedSetCodes(), FModel.getMagicDb().getEditions()::get)); - Collections.sort(allowedSets); + List allowedSets = qData.getFormat().getAllowedSetCodes().stream() + .map(editions::get) + .sorted().collect(Collectors.toList()); // Sort unlockable sets by date - List excludedSets = Lists.newArrayList(Iterables.transform(qData.getFormat().getLockedSets(), FModel.getMagicDb().getEditions()::get)); - Collections.sort(excludedSets); + List excludedSets = qData.getFormat().getLockedSets().stream() + .map(editions::get) + .sorted().collect(Collectors.toList()); // get a number of sets between an excluded and any included set List> excludedWithDistances = new ArrayList<>();