From d73166c03ba32e601a4493dd69cfa42045d5766c Mon Sep 17 00:00:00 2001 From: Neil McErlean Date: Tue, 8 Sep 2015 16:14:10 +0000 Subject: [PATCH] Addressing code review comments. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/classified_renditions@111696 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../test/util/FPUtils.java | 25 ++++++++++--------- .../test/util/FPUtilsUnitTest.java | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/FPUtils.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/FPUtils.java index d0e49771f9..335461a587 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/FPUtils.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/FPUtils.java @@ -18,6 +18,7 @@ */ package org.alfresco.module.org_alfresco_module_rm.test.util; +import static java.util.Arrays.asList; import static java.util.stream.Collectors.toList; import java.util.Collections; @@ -31,7 +32,7 @@ import java.util.stream.Stream; * Utility class to help with Java 8 FP stuff. * * @author Neil Mc Erlean - * @since 3.0.a + * @since 2.4.a */ public class FPUtils { @@ -41,7 +42,7 @@ public class FPUtils * * @param suppliers a vararg of {@link Supplier}s giving a sequence of values for the list. * @param the type of elements in the list. - * @return the list with each element retrieved from a {@code Supplier}. + * @return the list with each element being the first retrieved from a {@code Supplier}. */ public static List asListFrom(Supplier... suppliers) { @@ -57,12 +58,18 @@ public class FPUtils } } + /** + * This method is intended to work exactly like {@link #asSet(Object[])}} but it takes + * a vararg of {@code Supplier}s instead of actual objects. + * + * @param suppliers a vararg of {@link Supplier}s giving a sequence of values for the set. + * @param the type of elements in the set. + * @return the set with each element being the first retrieved from a {@code Supplier} (duplicates removed). + */ public static Set asSetFrom(Supplier... suppliers) { List l = asListFrom(suppliers); - Set result = new HashSet<>(); - result.addAll(l); - return result; + return new HashSet<>(l); } /** @@ -73,12 +80,6 @@ public class FPUtils */ public static Set asSet(T... objects) { - Set result = new HashSet<>(); - for (T obj : objects) - { - result.add(obj); - } - - return result; + return new HashSet<>(asList(objects)); } } \ No newline at end of file diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/FPUtilsUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/FPUtilsUnitTest.java index 206687295a..c15e92e275 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/FPUtilsUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/FPUtilsUnitTest.java @@ -34,7 +34,7 @@ import org.junit.Test; * Unit tests for {@link FPUtils}. * * @author Neil Mc Erlean - * @since 3.0.a + * @since 2.4.a */ public class FPUtilsUnitTest {