Class CollectionsUtils


  • public class CollectionsUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addListEntriesToMap​(java.util.List list, java.util.Map map, boolean keyIsValue)
      Add all the entries in the List as keys in the specified map.
      static void addMapEntriesToList​(java.util.Map map, java.util.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​(java.util.List objs, java.util.Map map, java.lang.String keyAccessor, java.lang.String valueAccessor)
      Given a List of objects, convert the values it contains to the passed in Map.
      static java.util.List convertToRows​(java.util.List objs, int rowSize)  
      static void getMapEntriesAsOrderedList​(java.util.Map map, java.util.List list)
      Given a Map return the entries in the Map in the passed in List in order.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CollectionsUtils

        public CollectionsUtils()
    • Method Detail

      • getMapEntriesAsOrderedList

        public static void getMapEntriesAsOrderedList​(java.util.Map map,
                                                      java.util.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​(java.util.Map map,
                                               java.util.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 java.util.List convertToRows​(java.util.List objs,
                                                   int rowSize)
      • convertListToMap

        public static void convertListToMap​(java.util.List objs,
                                            java.util.Map map,
                                            java.lang.String keyAccessor,
                                            java.lang.String valueAccessor)
                                     throws java.lang.IllegalAccessException,
                                            java.lang.reflect.InvocationTargetException,
                                            java.lang.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:
        java.lang.IllegalAccessException
        java.lang.reflect.InvocationTargetException
        java.lang.ClassCastException
      • addListEntriesToMap

        public static void addListEntriesToMap​(java.util.List list,
                                               java.util.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 "".