net.sourceforge.pmd.util

## Class ClassUtil

- java.lang.Object
- - net.sourceforge.pmd.util.ClassUtil

    public final class ClassUtil
    extends Object

Various class-related utility methods intended for mapping common java.lang types to their short short forms allowing end users to enter these names in UIs without the package prefixes.

Author:
  Brian Remedios

### Field Summary

Fields
`static Class<?>[]` `EMPTY_CLASS_ARRAY`

### Method Summary

Methods
`static Map<String,List<Method>>` `asMethodGroupsByTypeName(Method[] methods)` Return the methods as a map keyed by their common declaration types.
`static String` `asShortestName(Class<?> type)` Return the name of the type in its short form if its known to us otherwise return its name fully packaged.
`static Map<Class<?>,String>` `getClassShortNames()`
`static Class<?>` `getPrimitiveTypeFor(String name)` Returns the type(class) for the name specified or null if not found.
`static Class<?>` `getTypeFor(String shortName)` Attempt to determine the actual class given the short name.
`static Method` `methodFor(Class<?> clasz, String methodName, Class<?>[] paramTypes)` Attempts to return the specified method from the class provided but will walk up its superclasses until it finds a match.
`static String` `withoutPackageName(String fullTypeName)` Returns the abbreviated name of the type, without the package name

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

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

### Field Detail

#### EMPTY_CLASS_ARRAY

    public static final Class<?>[] EMPTY_CLASS_ARRAY

### Method Detail

#### getPrimitiveTypeFor

    public static Class<?> getPrimitiveTypeFor(String name)

Returns the type(class) for the name specified or null if not found.

Parameters:
  `name` - String
Returns:
  Class

#### getClassShortNames

    public static Map<Class<?>,String> getClassShortNames()

#### getTypeFor

    public static Class<?> getTypeFor(String shortName)

Attempt to determine the actual class given the short name.

Parameters:
  `shortName` - String
Returns:
  Class

#### asShortestName

    public static String asShortestName(Class<?> type)

Return the name of the type in its short form if its known to us otherwise return its name fully packaged.

Parameters:
  `type` -
Returns:
  String

#### withoutPackageName

    public static String withoutPackageName(String fullTypeName)

Returns the abbreviated name of the type, without the package name

Parameters:
  `fullTypeName` -
Returns:
  String

#### methodFor

    public static Method methodFor(Class<?> clasz,
                   String methodName,
                   Class<?>[] paramTypes)

Attempts to return the specified method from the class provided but will walk up its superclasses until it finds a match. Returns null if it doesn't.

Parameters:
  `clasz` - Class
  `methodName` - String
  `paramTypes` - Class[]
Returns:
  Method

#### asMethodGroupsByTypeName

    public static Map<String,List<Method>> asMethodGroupsByTypeName(Method[] methods)

Return the methods as a map keyed by their common declaration types.

Parameters:
  `methods` -
Returns:
  Map<String, List<Method>>