diff options
| author | Ben Culkin <scorpress@gmail.com> | 2020-04-13 18:40:41 -0400 |
|---|---|---|
| committer | Ben Culkin <scorpress@gmail.com> | 2020-04-13 18:40:41 -0400 |
| commit | d4ca769e542b2489b1e23cfcbdc3a0b7275b87cd (patch) | |
| tree | 1653a7399f97fb0c63ce62e3f60fd830d5c37f70 /base/src/main/java/bjc/utils/funcutils/EnumUtils.java | |
| parent | 2ac2e31a56ae59ee582e43a90c3495f86dd9ee7a (diff) | |
Cleanup pass
Cleanup pass to uniformize things
Diffstat (limited to 'base/src/main/java/bjc/utils/funcutils/EnumUtils.java')
| -rw-r--r-- | base/src/main/java/bjc/utils/funcutils/EnumUtils.java | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/base/src/main/java/bjc/utils/funcutils/EnumUtils.java b/base/src/main/java/bjc/utils/funcutils/EnumUtils.java index 37ebd50..e8898ca 100644 --- a/base/src/main/java/bjc/utils/funcutils/EnumUtils.java +++ b/base/src/main/java/bjc/utils/funcutils/EnumUtils.java @@ -16,29 +16,29 @@ public class EnumUtils { * Do an action for a random number of enum values. * * @param <E> - * The type of the enum. + * The type of the enum. * * @param clasz - * The enum class. + * The enum class. * * @param nValues - * The number of values to execute the action on. + * The number of values to execute the action on. * * @param action - * The action to perform on random values. + * The action to perform on random values. * * @param rnd - * The source of randomness to use. + * The source of randomness to use. */ - public static <E extends Enum<E>> void doForValues(final Class<E> clasz, final int nValues, - final Consumer<E> action, final Random rnd) { + public static <E extends Enum<E>> void doForValues(final Class<E> clasz, + final int nValues, final Consumer<E> action, final Random rnd) { final E[] enumValues = clasz.getEnumConstants(); final IList<E> valueList = new FunctionalList<>(enumValues); final int randomValueCount = enumValues.length - nValues; - for(int i = 0; i <= randomValueCount; i++) { + for (int i = 0; i <= randomValueCount; i++) { final E rDir = valueList.randItem(rnd::nextInt); valueList.removeMatching(rDir); @@ -51,17 +51,18 @@ public class EnumUtils { * Get a random value from an enum. * * @param <E> - * The type of the enum. + * The type of the enum. * * @param clasz - * The class of the enum. + * The class of the enum. * * @param rnd - * The random source to use. + * The random source to use. * * @return A random value from the specified enum. */ - public static <E extends Enum<E>> E getRandomValue(final Class<E> clasz, final Random rnd) { + public static <E extends Enum<E>> E getRandomValue(final Class<E> clasz, + final Random rnd) { final E[] enumValues = clasz.getEnumConstants(); return new FunctionalList<>(enumValues).randItem(rnd::nextInt); |
