Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sourceforge.pmd.util
Class CollectionUtil

    java.lang.Object
      net.sourceforge.pmd.util.CollectionUtil

public class CollectionUtil
extends java.lang.Object

Generic collection and array-related utility functions.

Version:
  $Revision$
Author:
  Brian Remedios

Field Summary
`static TypeMap` | `collectionClassesByNames`
`static TypeMap` | `collectionInterfacesByNames`

Method Summary
`static boolean` | `areEqual(java.lang.Object value, java.lang.Object otherValue)` A comprehensive isEqual method that handles nulls and arrays safely.
`static boolean` | `arraysAreEqual(java.lang.Object value, java.lang.Object otherValue)` Returns true if the objects are array instances and each of their elements compares via equals as well.
`static java.util.Set` | `asSet(java.lang.Object[] items)` Returns the items as a populated set.
`static java.lang.Class` | `getCollectionTypeFor(java.lang.String shortName)` Returns the collection type if we recognize it by its short name.
`static java.util.Map` | `invertedMapFrom(java.util.Map source)` Returns a map based on the source but with the key & values swapped.
`static boolean` | `isCollectionType(java.lang.Class clazzType, boolean includeInterfaces)` Return whether we can identify the typeName as a java.util collection class or interface as specified.
`static boolean` | `isCollectionType(java.lang.String typeName, boolean includeInterfaces)` Return whether we can identify the typeName as a java.util collection class or interface as specified.
`static java.util.Map` | `mapFrom(java.lang.Object[][] keyValueSets)` Creates and returns a map populated with the keyValuesSets where the value held by the tuples are they key and value in that order.
`static boolean` | `valuesAreTransitivelyEqual(java.lang.Object[] thisArray, java.lang.Object[] thatArray)` Returns whether the arrays are equal by examining each of their elements, even if they are arrays themselves.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### collectionInterfacesByNames

    public static final TypeMap collectionInterfacesByNames

### collectionClassesByNames

    public static final TypeMap collectionClassesByNames

Method Detail

### getCollectionTypeFor

    public static java.lang.Class getCollectionTypeFor(java.lang.String shortName)

  Returns the collection type if we recognize it by its short name.

  Parameters:
    `shortName` - String
  Returns:
    Class

### isCollectionType

    public static boolean isCollectionType(java.lang.String typeName,
                                           boolean includeInterfaces)

  Return whether we can identify the typeName as a java.util collection class or interface as specified.

  Parameters:
    `typeName` - String
    `includeInterfaces` - boolean
  Returns:
    boolean

### isCollectionType

    public static boolean isCollectionType(java.lang.Class clazzType,
                                           boolean includeInterfaces)

  Return whether we can identify the typeName as a java.util collection class or interface as specified.

  Parameters:
    `clazzType` - Class
    `includeInterfaces` - boolean
  Returns:
    boolean

### asSet

    public static java.util.Set asSet(java.lang.Object[] items)

  Returns the items as a populated set.

  Parameters:
    `items` - Object[]
  Returns:
    Set

### mapFrom

    public static java.util.Map mapFrom(java.lang.Object[][] keyValueSets)

  Creates and returns a map populated with the keyValuesSets where the value held by the tuples are they key and value in that order.

  Parameters:
    `keyValueSets` - Object[][]
  Returns:
    Map

### invertedMapFrom

    public static java.util.Map invertedMapFrom(java.util.Map source)

  Returns a map based on the source but with the key & values swapped.

  Parameters:
    `source` - Map
  Returns:
    Map

### arraysAreEqual

    public static final boolean arraysAreEqual(java.lang.Object value,
                                               java.lang.Object otherValue)

  Returns true if the objects are array instances and each of their elements compares via equals as well.

  Parameters:
    `value` - Object
    `otherValue` - Object
  Returns:
    boolean

### valuesAreTransitivelyEqual

    public static final boolean valuesAreTransitivelyEqual(java.lang.Object[] thisArray,
                                                           java.lang.Object[] thatArray)

  Returns whether the arrays are equal by examining each of their elements, even if they are arrays themselves.

  Parameters:
    `thisArray` - Object[]
    `thatArray` - Object[]
  Returns:
    boolean

### areEqual

    public static final boolean areEqual(java.lang.Object value,
                                         java.lang.Object otherValue)

  A comprehensive isEqual method that handles nulls and arrays safely.

  Parameters:
    `value` - Object
    `otherValue` - Object
  Returns:
    boolean

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2006 InfoEther. All Rights Reserved.