Package glide.utils
Class Java8Utils
- java.lang.Object
-
- glide.utils.Java8Utils
-
public class Java8Utils extends java.lang.ObjectUtility methods for Java 8 compatibility. Provides alternatives for Java 9+ APIs.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcompareByteArrays(byte[] a, byte[] b)Compares two byte arrays lexicographically.static <T> java.util.List<T>createList()Creates an empty list.static <T> java.util.List<T>createList(T... elements)Creates a list with elements.static <K,V>
java.util.Map<K,V>createMap()Creates an empty HashMap.static <K,V>
java.util.Map<K,V>createMap(K k1, V v1)Creates a HashMap with one key-value pair.static <K,V>
java.util.Map<K,V>createMap(K k1, V v1, K k2, V v2)Creates a HashMap with two key-value pairs.static <K,V>
java.util.Map<K,V>createMap(K k1, V v1, K k2, V v2, K k3, V v3)Creates a HashMap with three key-value pairs.static <K,V>
java.util.Map<K,V>createMap(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4)Creates a HashMap with four key-value pairs.static <K,V>
java.util.Map<K,V>createMap(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5)Creates a HashMap with five key-value pairs.static <K,V>
java.util.Map<K,V>createMap(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6)Creates a HashMap with six key-value pairs.static <K,V>
java.util.Map<K,V>createMap(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7)Creates a HashMap with seven key-value pairs.static <T> java.util.Set<T>createSet(T... elements)Creates a HashSet with elements.static java.lang.Stringrepeat(java.lang.String str, int count)Repeats a string n times.
-
-
-
Method Detail
-
compareByteArrays
public static int compareByteArrays(byte[] a, byte[] b)Compares two byte arrays lexicographically.- Parameters:
a- the first array to compareb- the second array to compare- Returns:
- the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array
-
createMap
public static <K,V> java.util.Map<K,V> createMap()
Creates an empty HashMap.- Type Parameters:
K- the type of keysV- the type of values- Returns:
- an empty HashMap
-
createMap
public static <K,V> java.util.Map<K,V> createMap(K k1, V v1)Creates a HashMap with one key-value pair.- Type Parameters:
K- the type of keysV- the type of values- Parameters:
k1- the keyv1- the value- Returns:
- a HashMap containing the key-value pair
-
createMap
public static <K,V> java.util.Map<K,V> createMap(K k1, V v1, K k2, V v2)Creates a HashMap with two key-value pairs.- Type Parameters:
K- the type of keysV- the type of values- Parameters:
k1- the first keyv1- the first valuek2- the second keyv2- the second value- Returns:
- a HashMap containing the key-value pairs
-
createMap
public static <K,V> java.util.Map<K,V> createMap(K k1, V v1, K k2, V v2, K k3, V v3)Creates a HashMap with three key-value pairs.- Type Parameters:
K- the type of keysV- the type of values- Parameters:
k1- the first keyv1- the first valuek2- the second keyv2- the second valuek3- the third keyv3- the third value- Returns:
- a HashMap containing the key-value pairs
-
createMap
public static <K,V> java.util.Map<K,V> createMap(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4)Creates a HashMap with four key-value pairs.- Type Parameters:
K- the type of keysV- the type of values- Parameters:
k1- the first keyv1- the first valuek2- the second keyv2- the second valuek3- the third keyv3- the third valuek4- the fourth keyv4- the fourth value- Returns:
- a HashMap containing the key-value pairs
-
createMap
public static <K,V> java.util.Map<K,V> createMap(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5)Creates a HashMap with five key-value pairs.- Type Parameters:
K- the type of keysV- the type of values- Parameters:
k1- the first keyv1- the first valuek2- the second keyv2- the second valuek3- the third keyv3- the third valuek4- the fourth keyv4- the fourth valuek5- the fifth keyv5- the fifth value- Returns:
- a HashMap containing the key-value pairs
-
createMap
public static <K,V> java.util.Map<K,V> createMap(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6)Creates a HashMap with six key-value pairs.- Type Parameters:
K- the type of keysV- the type of values- Parameters:
k1- the first keyv1- the first valuek2- the second keyv2- the second valuek3- the third keyv3- the third valuek4- the fourth keyv4- the fourth valuek5- the fifth keyv5- the fifth valuek6- the sixth keyv6- the sixth value- Returns:
- a HashMap containing the key-value pairs
-
createMap
public static <K,V> java.util.Map<K,V> createMap(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7)Creates a HashMap with seven key-value pairs.- Type Parameters:
K- the type of keysV- the type of values- Parameters:
k1- the first keyv1- the first valuek2- the second keyv2- the second valuek3- the third keyv3- the third valuek4- the fourth keyv4- the fourth valuek5- the fifth keyv5- the fifth valuek6- the sixth keyv6- the sixth valuek7- the seventh keyv7- the seventh value- Returns:
- a HashMap containing the key-value pairs
-
createSet
@SafeVarargs public static <T> java.util.Set<T> createSet(T... elements)
Creates a HashSet with elements.- Type Parameters:
T- the type of elements- Parameters:
elements- the elements- Returns:
- a HashSet containing the elements
-
createList
public static <T> java.util.List<T> createList()
Creates an empty list.- Type Parameters:
T- the type of elements- Returns:
- an empty list
-
createList
@SafeVarargs public static <T> java.util.List<T> createList(T... elements)
Creates a list with elements.- Type Parameters:
T- the type of elements- Parameters:
elements- the elements- Returns:
- a list containing the elements
-
repeat
public static java.lang.String repeat(java.lang.String str, int count)Repeats a string n times.- Parameters:
str- the string to repeatcount- the number of times to repeat- Returns:
- the repeated string
- Throws:
java.lang.IllegalArgumentException- if count is negative
-
-