Package host.anzo.commons.utils
Class StreamUtils
java.lang.Object
host.anzo.commons.utils.StreamUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclosedRange(int startInclusive, int endInclusive) Generates a list of integers representing a closed range from the specified start to end values.static <K,V extends Comparable<V>>
Map<K, V> sortMapByValue(@NotNull Map<K, V> map, boolean isReverseOrder) Sorts a map by its values in either ascending or descending order.
-
Constructor Details
-
StreamUtils
public StreamUtils()
-
-
Method Details
-
closedRange
Generates a list of integers representing a closed range from the specified start to end values.- Parameters:
startInclusive- The starting value of the range, inclusive.endInclusive- The ending value of the range, inclusive.- Returns:
- A list containing all integers from startInclusive to endInclusive, inclusive.
-
sortMapByValue
public static <K,V extends Comparable<V>> Map<K,V> sortMapByValue(@NotNull @NotNull Map<K, V> map, boolean isReverseOrder) Sorts a map by its values in either ascending or descending order.- Type Parameters:
K- The type of keys in the map.V- The type of values in the map, which must be comparable.- Parameters:
map- The map to be sorted, where keys are of type K and values are of type V.isReverseOrder- A boolean indicating whether to sort in reverse (descending) order.- Returns:
- A new LinkedHashMap containing the entries of the original map sorted by value.
-