org.eclipse.emf.compare.util
Class ClassUtils

java.lang.Object
  extended by org.eclipse.emf.compare.util.ClassUtils

public final class ClassUtils
extends java.lang.Object

Provides utility methods to get information on Class objects.


Method Summary
static boolean classEquals(java.lang.Class<?> class1, java.lang.Class<?> class2)
          This will test equality between two classes.
static boolean hasMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.Class<?>... parameters)
          Iterates through a given Class public Methods to determine if it declares a method of the given name and parameters.
static java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object... parameters)
          Convenience method to reflectively invoke a given method on the given object with the given parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

classEquals

public static boolean classEquals(java.lang.Class<?> class1,
                                  java.lang.Class<?> class2)
This will test equality between two classes.

We'll assume that primitives types are equal to their wrappers so that parameterEquals(java.lang.Integer, int) returns True.

Parameters:
class1 - First of the two classes to test for equality.
class2 - Second of the two classes to test for equality.
Returns:
True if the two classes are considered equal, False otherwise.

hasMethod

public static boolean hasMethod(java.lang.Class<?> clazz,
                                java.lang.String methodName,
                                java.lang.Class<?>... parameters)
Iterates through a given Class public Methods to determine if it declares a method of the given name and parameters.

Parameters:
clazz - Class to visit.
methodName - Name of the method we search for.
parameters - Types of the researched method parameters.
Returns:
True if the given Class object declares a Method called methodName.

invokeMethod

public static java.lang.Object invokeMethod(java.lang.Object object,
                                            java.lang.String methodName,
                                            java.lang.Object... parameters)
Convenience method to reflectively invoke a given method on the given object with the given parameters. This implementation takes care of checking if the method exists beforehand and will return null if it does not.

Parameters:
object - Invocation target.
methodName - Name of the method to invoke.
parameters - Parameters with which to invoke the method.
Returns:
Result of the invocation or null if the method does not exist according to hasMethod(Class, String, Class...).

Copyright 2006 IBM Corporation and others.
All Rights Reserved.