org.codehaus.plexus.util

## Class CollectionUtils

- java.lang.Object
- - org.codehaus.plexus.util.CollectionUtils

-     public class CollectionUtils
      extends java.lang.Object

  Version:
    $Id: CollectionUtils.java 8055 2009-01-16 12:45:08Z vsiveton $
  Author:
    olamy

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CollectionUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.util.Map` | `getCardinalityMap(java.util.Collection col)` Returns a `Map` mapping each unique element in the given `Collection` to an `Integer` representing the number of occurances of that element in the `Collection`.
    `static java.util.Collection` | `intersection(java.util.Collection a, java.util.Collection b)` Returns a `Collection` containing the intersection of the given `Collection`s.
    `static java.util.List` | `iteratorToList(java.util.Iterator it)`
    `static java.util.Map` | `mergeMaps(java.util.Map[] maps)` Take a series of `Map`s and merge them where the ordering of the array from 0..n is the dominant order.
    `static java.util.Map` | `mergeMaps(java.util.Map dominantMap, java.util.Map recessiveMap)` Take a dominant and recessive Map and merge the key:value pairs where the recessive Map may add key:value pairs to the dominant Map but may not override any existing key:value pairs.
    `static java.util.Collection` | `subtract(java.util.Collection a, java.util.Collection b)` Returns a `Collection` containing `a - b`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CollectionUtils

          public CollectionUtils()

  - ### Method Detail

    - #### mergeMaps

          public static java.util.Map mergeMaps(java.util.Map dominantMap,
                                                java.util.Map recessiveMap)

      Take a dominant and recessive Map and merge the key:value pairs where the recessive Map may add key:value pairs to the dominant Map but may not override any existing key:value pairs. If we have two Maps, a dominant and recessive, and their respective keys are as follows: dominantMapKeys = { a, b, c, d, e, f } recessiveMapKeys = { a, b, c, x, y, z } Then the result should be the following: resultantKeys = { a, b, c, d, e, f, x, y, z }
      Parameters:
        `dominantMap` - Dominant Map.
        `recessiveMap` - Recessive Map.
      Returns:
        The result map with combined dominant and recessive values.

    - #### mergeMaps

          public static java.util.Map mergeMaps(java.util.Map[] maps)

      Take a series of `Map`s and merge them where the ordering of the array from 0..n is the dominant order.
      Parameters:
        `maps` - An array of Maps to merge.
      Returns:
        Map The result Map produced after the merging process.

    - #### intersection

          public static java.util.Collection intersection(java.util.Collection a,
                                                          java.util.Collection b)

      Returns a `Collection` containing the intersection of the given `Collection`s.

      The cardinality of each element in the returned `Collection` will be equal to the minimum of the cardinality of that element in the two given `Collection`s.

      See Also:
        `Collection.retainAll(java.util.Collection<?>)`

    - #### subtract

          public static java.util.Collection subtract(java.util.Collection a,
                                                      java.util.Collection b)

      Returns a `Collection` containing `a - b`. The cardinality of each element e in the returned `Collection` will be the cardinality of e in a minus the cardinality of e in b, or zero, whichever is greater.
      See Also:
        `Collection.removeAll(java.util.Collection<?>)`

    - #### getCardinalityMap

          public static java.util.Map getCardinalityMap(java.util.Collection col)

      Returns a `Map` mapping each unique element in the given `Collection` to an `Integer` representing the number of occurances of that element in the `Collection`. An entry that maps to `null` indicates that the element does not appear in the given `Collection`.

    - #### iteratorToList

          public static java.util.List iteratorToList(java.util.Iterator it)