From 15abeb294dda17d4ba0a8959dc7bb10138d5383f Mon Sep 17 00:00:00 2001 From: Fuzzlemann Date: Tue, 1 Aug 2017 20:34:23 +0200 Subject: [PATCH] Inline variables Convert some things to Method Reference Add randomEnum(Class) --- .../com/djrapitops/plan/database/databases/SQLDB.java | 2 +- Plan/src/test/java/utils/RandomData.java | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java index c6a824273..b78955a41 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java @@ -450,7 +450,7 @@ public abstract class SQLDB extends Database { .map(UserData::getWorldTimes) .map(WorldTimes::getTimes) .map(Map::keySet) - .flatMap(keySet -> keySet.stream()) + .flatMap(Collection::stream) .distinct() .collect(Collectors.toList()); for (Map.Entry entrySet : userDatas.entrySet()) { diff --git a/Plan/src/test/java/utils/RandomData.java b/Plan/src/test/java/utils/RandomData.java index 8b627dfbf..82cfd194a 100644 --- a/Plan/src/test/java/utils/RandomData.java +++ b/Plan/src/test/java/utils/RandomData.java @@ -34,8 +34,7 @@ public class RandomData { * Random enough. */ public static String randomString(int size) { - String randomString = UUID.randomUUID().toString().replaceAll("-", "").substring(0, size); - return randomString; + return UUID.randomUUID().toString().replaceAll("-", "").substring(0, size); } public static List randomWebUsers() throws PassEncryptUtil.CannotPerformOperationException { @@ -75,7 +74,7 @@ public class RandomData { public static List randomHandlingInfo() { List test = new ArrayList<>(); for (int i = 0; i < 20; i++) { - test.add(new HandlingInfo(UUID.randomUUID(), InfoType.OTHER, r.nextLong()) { + test.add(new HandlingInfo(UUID.randomUUID(), randomEnum(InfoType.class), r.nextLong()) { @Override public boolean process(UserData uData) { return false; @@ -85,5 +84,8 @@ public class RandomData { return test; } - + public static T randomEnum(Class clazz) { + int x = r.nextInt(clazz.getEnumConstants().length); + return clazz.getEnumConstants()[x]; + } }