Class CollectionsUtils


  • public class CollectionsUtils
    extends Object
    • Constructor Detail

      • CollectionsUtils

        public CollectionsUtils()
    • 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.
      • convertToRows

        public static List convertToRows​(List objs,
                                         int rowSize)
      • 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 be accessors and specify the key and value for the map respectively. Set valueAccessor to null 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 to null 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" to true to put the entry from the List as the value for the map as well, if it's set to false 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 "".