Package com.github.raimannma.methods
Enum Utils
- All Implemented Interfaces:
Serializable
,Comparable<Utils>
,Constable
public enum Utils extends Enum<Utils>
Utils.
Here are some useful functions.
- Author:
- Manuel Raimann
-
Nested Class Summary
-
Method Summary
Modifier and Type Method Description static <T> T
pickRandom(@NotNull Collection<T> collection)
Chooses a random element from the given collection.static <T> T
pickRandom(@NotNull T[] arr)
Chooses a random element from the given array.static boolean
randBoolean()
Generates a random boolean.static double
randDouble()
Generates a random double between min and max.static double
randDouble(double max)
Generates a random double between min and max.static double
randDouble(double min, double max)
Generates a random double between min and max.static int
randInt(int max)
Generates a random integer between min and max.static int
randInt(int min, int max)
Generates a random integer between min and max.static <T> boolean
setsEqual(Set<T> set, Set<T> set1)
Checks if two sets are equalstatic Utils
valueOf(String name)
Returns the enum constant of this type with the specified name.static Utils[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Method Details
-
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
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 nameNullPointerException
- 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 valuemax
- 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 valuemax
- 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
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
Checks if two sets are equalDOES NOT CHECK ORDER !
- Type Parameters:
T
- Generic type parameter- Parameters:
set
- first setset1
- second set- Returns:
- are both sets equal?
-