Inline variables

Convert some things to Method Reference
Add randomEnum(Class<T>)
This commit is contained in:
Fuzzlemann 2017-08-01 20:34:23 +02:00
parent c2c3ce0daa
commit 15abeb294d
2 changed files with 7 additions and 5 deletions

View File

@ -450,7 +450,7 @@ public abstract class SQLDB extends Database {
.map(UserData::getWorldTimes) .map(UserData::getWorldTimes)
.map(WorldTimes::getTimes) .map(WorldTimes::getTimes)
.map(Map::keySet) .map(Map::keySet)
.flatMap(keySet -> keySet.stream()) .flatMap(Collection::stream)
.distinct() .distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
for (Map.Entry<UUID, UserData> entrySet : userDatas.entrySet()) { for (Map.Entry<UUID, UserData> entrySet : userDatas.entrySet()) {

View File

@ -34,8 +34,7 @@ public class RandomData {
* Random enough. * Random enough.
*/ */
public static String randomString(int size) { public static String randomString(int size) {
String randomString = UUID.randomUUID().toString().replaceAll("-", "").substring(0, size); return UUID.randomUUID().toString().replaceAll("-", "").substring(0, size);
return randomString;
} }
public static List<WebUser> randomWebUsers() throws PassEncryptUtil.CannotPerformOperationException { public static List<WebUser> randomWebUsers() throws PassEncryptUtil.CannotPerformOperationException {
@ -75,7 +74,7 @@ public class RandomData {
public static List<HandlingInfo> randomHandlingInfo() { public static List<HandlingInfo> randomHandlingInfo() {
List<HandlingInfo> test = new ArrayList<>(); List<HandlingInfo> test = new ArrayList<>();
for (int i = 0; i < 20; i++) { 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 @Override
public boolean process(UserData uData) { public boolean process(UserData uData) {
return false; return false;
@ -85,5 +84,8 @@ public class RandomData {
return test; return test;
} }
public static <T extends Enum> T randomEnum(Class<T> clazz) {
int x = r.nextInt(clazz.getEnumConstants().length);
return clazz.getEnumConstants()[x];
}
} }