From 5e569b597a3a86ed249a37241ca246ea9fa3a157 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 5 Aug 2021 09:04:01 -0400 Subject: [PATCH] made randomutil method generic --- Mage/src/main/java/mage/util/RandomUtil.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Mage/src/main/java/mage/util/RandomUtil.java b/Mage/src/main/java/mage/util/RandomUtil.java index f1febad725..eebff33234 100644 --- a/Mage/src/main/java/mage/util/RandomUtil.java +++ b/Mage/src/main/java/mage/util/RandomUtil.java @@ -1,9 +1,9 @@ package mage.util; import java.awt.*; +import java.io.Serializable; import java.util.Random; import java.util.Set; -import java.util.UUID; /** * Created by IGOUDT on 5-9-2016. @@ -43,13 +43,13 @@ public final class RandomUtil { random.setSeed(newSeed); } - public static UUID randomFromSet(Set uuids) { - if (uuids.size() < 2) { - return uuids.stream().findFirst().orElse(null); + public static T randomFromSet(Set collection) { + if (collection.size() < 2) { + return collection.stream().findFirst().orElse(null); } - int rand = nextInt(uuids.size()); + int rand = nextInt(collection.size()); int count = 0; - for (UUID currentId : uuids) { + for (T currentId : collection) { if (count == rand) { return currentId; }