Enum Utils

java.lang.Object
java.lang.Enum<Utils>
com.github.raimannma.methods.Utils
All Implemented Interfaces:
Serializable, Comparable<Utils>, Constable

public enum Utils
extends Enum<Utils>
Utils.

Here are some useful functions.

Author:
Manuel Raimann
  • Method Details

    • values

      public static Utils[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static Utils valueOf​(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • randInt

      public static int randInt​(int min, int max)
      Generates a random integer between min and max.
      Parameters:
      min - the minimum value
      max - the maximum value
      Returns:
      the random integer between min and max
    • randDouble

      public static double randDouble​(double min, double max)
      Generates a random double between min and max.
      Parameters:
      min - the minimum value
      max - the maximum value
      Returns:
      the random double between min and max
    • randDouble

      public static double randDouble​(double max)
      Generates a random double between min and max.
      Parameters:
      max - the maximum value
      Returns:
      the random double between 0 and max
    • pickRandom

      public static <T> T pickRandom​(@NotNull @NotNull T[] arr)
      Chooses a random element from the given array.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      arr - the input array
      Returns:
      the random element from the input array
    • randInt

      public static int randInt​(int max)
      Generates a random integer between min and max.
      Parameters:
      max - the maximum value
      Returns:
      the random integer between 0 and max
    • pickRandom

      public static <T> T pickRandom​(@NotNull @NotNull Collection<T> collection)
      Chooses a random element from the given collection.
      Type Parameters:
      T - the type of the collection elements
      Parameters:
      collection - the input collection
      Returns:
      the random element from the input collection
    • randDouble

      public static double randDouble()
      Generates a random double between min and max.
      Returns:
      the random double between 0 and 1
    • randBoolean

      public static boolean randBoolean()
      Generates a random boolean.
      Returns:
      the random boolean
    • setsEqual

      public static <T> boolean setsEqual​(Set<T> set, Set<T> set1)
      Checks if two sets are equal

      DOES NOT CHECK ORDER !

      Type Parameters:
      T - Generic type parameter
      Parameters:
      set - first set
      set1 - second set
      Returns:
      are both sets equal?