com.vbs.spring.versioning
Class VersioningUtils

java.lang.Object
  extended by com.vbs.spring.versioning.VersioningUtils

public final class VersioningUtils
extends java.lang.Object

Some commonly called static helper methods.

Author:
Mike Whitfield (mike@virtual-businesses.com)

Constructor Summary
VersioningUtils()
           
 
Method Summary
(package private) static java.lang.reflect.Method findDeclaredMethod(java.lang.Class<?> clazz, java.lang.reflect.Method method, boolean mandatory)
          Returns the Method on the class argument that matches the method in name, arguments, returned type and modifiers, or null if no method of the same name and arguments exists on the class and the method is not considered mandatory.
(package private) static java.lang.Class<?>[] getArgumentClasses(java.lang.Object[] methodArgs)
          Returns the type of each argument.
(package private) static java.lang.String getMethodSignatureAsString(java.lang.reflect.Method method)
          Returns the method's signature as a string in the same format as Method.toString(), but excluding the declaring class.
(package private) static java.lang.String getMethodSignatureString(java.lang.String methodName, java.lang.Class<?>[] methodParameterTypes)
          Returns the method's signature as a string in the same format as Method.toString(), but excluding the return type and modifiers.
(package private) static java.lang.String getMethodSignatureString(java.lang.String methodName, java.lang.Object[] methodParameters)
          Returns the method's signature as a string in the same format as Method.toString(), but excluding the return type and modifiers.
(package private) static boolean isVersionDependentClass(java.lang.Class<?> clazz)
          Return true if the given class is annotated as a VersionDependentClass.
(package private) static boolean isVersioned(java.lang.Class<?> clazz)
          Return true if the given class is annotated as a VersionedClass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersioningUtils

public VersioningUtils()
Method Detail

isVersionDependentClass

static boolean isVersionDependentClass(java.lang.Class<?> clazz)
Return true if the given class is annotated as a VersionDependentClass.

Parameters:
clazz - the class being checked.
Returns:
true if the given class is annotated as VersionDependentClass.

isVersioned

static boolean isVersioned(java.lang.Class<?> clazz)
Return true if the given class is annotated as a VersionedClass.

Parameters:
clazz - the class being checked.
Returns:
true if the given class is annotated as VersionDependentClass.

getMethodSignatureString

static java.lang.String getMethodSignatureString(java.lang.String methodName,
                                                 java.lang.Object[] methodParameters)
Returns the method's signature as a string in the same format as Method.toString(), but excluding the return type and modifiers.

Parameters:
methodName - the name of the method.
methodParameters - the arguments for the method.
Returns:
the method's signature as a string.

getMethodSignatureString

static java.lang.String getMethodSignatureString(java.lang.String methodName,
                                                 java.lang.Class<?>[] methodParameterTypes)
Returns the method's signature as a string in the same format as Method.toString(), but excluding the return type and modifiers.

Parameters:
methodName - the name of the method.
methodParameterTypes - the parameter types for the method.
Returns:
the method's signature as a string.

getMethodSignatureAsString

static java.lang.String getMethodSignatureAsString(java.lang.reflect.Method method)
Returns the method's signature as a string in the same format as Method.toString(), but excluding the declaring class.

Parameters:
method - the method.
Returns:
the method's signature as a string.

getArgumentClasses

static java.lang.Class<?>[] getArgumentClasses(java.lang.Object[] methodArgs)
Returns the type of each argument.

Parameters:
methodArgs - the array of objects passed to a method.
Returns:
the type of each argument.

findDeclaredMethod

static java.lang.reflect.Method findDeclaredMethod(java.lang.Class<?> clazz,
                                                   java.lang.reflect.Method method,
                                                   boolean mandatory)
Returns the Method on the class argument that matches the method in name, arguments, returned type and modifiers, or null if no method of the same name and arguments exists on the class and the method is not considered mandatory. If the method is found, it's return type and modifiers much match those of the passed method.

Parameters:
clazz - the class on which the method may be present.
method - the method for which a match may be found on clazz.
mandatory - true if the method must exist on clazz.
Returns:
the matching method on the clazz.