Package com.gentlyweb.utils
Class CollectionsUtils
- java.lang.Object
-
- com.gentlyweb.utils.CollectionsUtils
-
public class CollectionsUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description CollectionsUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addListEntriesToMap(List list, Map map, boolean keyIsValue)
Add all the entries in the List as keys in the specified map.static void
addMapEntriesToList(Map map, List list)
Get all the entries in the Map object out and place into the List passed in, just add at the bottom.static void
convertListToMap(List objs, Map map, String keyAccessor, String valueAccessor)
Given a List of objects, convert the values it contains to the passed in Map.static List
convertToRows(List objs, int rowSize)
static void
getMapEntriesAsOrderedList(Map map, List list)
Given a Map return the entries in the Map in the passed in List in order.
-
-
-
Method Detail
-
getMapEntriesAsOrderedList
public static void getMapEntriesAsOrderedList(Map map, List list)
Given a Map return the entries in the Map in the passed in List in order.- Parameters:
map
- The Map to use.list
- The List to fill up.
-
addMapEntriesToList
public static void addMapEntriesToList(Map map, List list)
Get all the entries in the Map object out and place into the List passed in, just add at the bottom.- Parameters:
map
- The Map to get objects out of.list
- The List to add objects to the end of. We add the Map.Entry.
-
convertListToMap
public static void convertListToMap(List objs, Map map, String keyAccessor, String valueAccessor) throws IllegalAccessException, InvocationTargetException, ClassCastException
Given a List of objects, convert the values it contains to the passed in Map. The keyAccessor and valueAccessor parameters should beaccessors
and specify the key and value for the map respectively. Set valueAccessor tonull
to mean that the object from the List should be added as the value. Note: all the objects in the list MUST be of the same type, to determine the class the first object in the list is examined.- Parameters:
objs
- The objects to convert.map
- The Map to add the objects to.keyAccessor
- The accessor for the key to set in the map.valueAccessor
- The accessor for the value to set in the map, set tonull
to get the object added.- Throws:
IllegalAccessException
InvocationTargetException
ClassCastException
-
addListEntriesToMap
public static void addListEntriesToMap(List list, Map map, boolean keyIsValue)
Add all the entries in the List as keys in the specified map. Set "keyIsValue" totrue
to put the entry from the List as the value for the map as well, if it's set tofalse
then we use "".- Parameters:
list
- The List to get entries from.map
- The Map to add entries to.keyIsValue
- Indicate whether we should use the List entry as the value as well or "".
-
-