Package com.jbstrap.core.utils
Class MapUtils
java.lang.Object
com.jbstrap.core.utils.MapUtils
Map handling utility methods
- Since:
- 4.0
- Author:
- JBStrap
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> Map.Entry<K, V> getElementFromIndex(Map<K, V> input, Integer index) Gets an element of a map, based on the specified indexstatic <K,V> void moveMapElement(Map<K, V> input, Integer sourceIndex, Integer targetIndex) Moves the specified map element to another positionstatic <K,V> void putElementAtIndex(Map<K, V> input, Integer index, Map.Entry<K, V> entry) Places an element in the specified map, by the specified index.static <K,V> void putElementAtIndex(Map<K, V> input, Integer index, K key, V value) Places an element in the specified map, by the specified index.
-
Method Details
-
getElementFromIndex
Gets an element of a map, based on the specified index- Type Parameters:
K- The map key typeV- The map value type- Parameters:
input- The source mapindex- The index of the element- Returns:
- The map element corresponding to the specified index, or
nullif not found
-
putElementAtIndex
Places an element in the specified map, by the specified index. The values after the specified index will be shifted by one position.- Type Parameters:
K- The map key typeV- The map value type- Parameters:
input- The map where the element will be insertedindex- The index of the elemententry- The element that will be inserted
-
putElementAtIndex
Places an element in the specified map, by the specified index. The values after the specified index will be shifted by one position.- Type Parameters:
K- The map key typeV- The map value type- Parameters:
input- The map where the element will be insertedindex- The index of the elementkey- The key of the element that will be insertedvalue- The value of the element that will be inserted
-
moveMapElement
Moves the specified map element to another position- Type Parameters:
K- The map key typeV- The map value type- Parameters:
input- The source map that has the element that needs to be movedsourceIndex- The source index of the elementtargetIndex- The target index where the element will be moved to
-