Spring Data Commons

org.springframework.data.repository.util
Class ClassUtils

java.lang.Object
  extended by org.springframework.data.repository.util.ClassUtils

public abstract class ClassUtils
extends java.lang.Object

Utility class to work with classes.

Author:
Oliver Gierke

Method Summary
static void assertReturnTypeAssignable(java.lang.reflect.Method method, java.lang.Class<?>... types)
          Asserts the given Method's return type to be one of the given types.
static int getNumberOfOccurences(java.lang.reflect.Method method, java.lang.Class<?> type)
          Returns the number of occurences of the given type in the given Methods parameters.
static boolean hasParameterOfType(java.lang.reflect.Method method, java.lang.Class<?> type)
          Returns whether the given Method has a parameter of the given type.
static boolean hasProperty(java.lang.Class<?> type, java.lang.String property)
          Returns whether the given class contains a property with the given name.
static boolean isGenericRepositoryInterface(java.lang.Class<?> interfaze)
          Returns wthere the given type is the Repository interface.
static boolean isGenericRepositoryInterface(java.lang.String interfaceName)
          Returns whether the given type name is a repository interface name.
static boolean isOfType(java.lang.Object object, java.util.Collection<java.lang.Class<?>> types)
          Returns whether the given object is of one of the given types.
static void unwrapReflectionException(java.lang.Exception ex)
          Helper method to extract the original exception that can possibly occur during a reflection call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

hasProperty

public static boolean hasProperty(java.lang.Class<?> type,
                                  java.lang.String property)
Returns whether the given class contains a property with the given name.

Parameters:
fieldName -
Returns:

isGenericRepositoryInterface

public static boolean isGenericRepositoryInterface(java.lang.Class<?> interfaze)
Returns wthere the given type is the Repository interface.

Parameters:
interfaze -
Returns:

isGenericRepositoryInterface

public static boolean isGenericRepositoryInterface(java.lang.String interfaceName)
Returns whether the given type name is a repository interface name.

Parameters:
interfaceName -
Returns:

getNumberOfOccurences

public static int getNumberOfOccurences(java.lang.reflect.Method method,
                                        java.lang.Class<?> type)
Returns the number of occurences of the given type in the given Methods parameters.

Parameters:
method -
type -
Returns:

assertReturnTypeAssignable

public static void assertReturnTypeAssignable(java.lang.reflect.Method method,
                                              java.lang.Class<?>... types)
Asserts the given Method's return type to be one of the given types.

Parameters:
method -
types -

isOfType

public static boolean isOfType(java.lang.Object object,
                               java.util.Collection<java.lang.Class<?>> types)
Returns whether the given object is of one of the given types. Will return false for null.

Parameters:
object -
types -
Returns:

hasParameterOfType

public static boolean hasParameterOfType(java.lang.reflect.Method method,
                                         java.lang.Class<?> type)
Returns whether the given Method has a parameter of the given type.

Parameters:
method -
type -
Returns:

unwrapReflectionException

public static void unwrapReflectionException(java.lang.Exception ex)
                                      throws java.lang.Throwable
Helper method to extract the original exception that can possibly occur during a reflection call.

Parameters:
ex -
Throws:
java.lang.Throwable

Spring Data Commons

Copyright © 2012. All Rights Reserved.