Package org.codehaus.groovy.runtime
Class MetaClassHelper
- java.lang.Object
- 
- org.codehaus.groovy.runtime.MetaClassHelper
 
- 
 public class MetaClassHelper extends Object 
- 
- 
Field SummaryFields Modifier and Type Field Description static Object[]ARRAY_WITH_NULLstatic Object[]EMPTY_ARRAYstatic Class[]EMPTY_CLASS_ARRAYstatic Class[]EMPTY_TYPE_ARRAYprotected static LoggerLOG
 - 
Constructor SummaryConstructors Constructor Description MetaClassHelper()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static booleanaccessibleToConstructor(Class at, Constructor constructor)static ObjectasPrimitiveArray(List list, Class parameterType)static Object[]asWrapperArray(Object parameters, Class componentType)static longcalculateParameterDistance(Class[] arguments, ParameterTypes pt)static Stringcapitalize(String property)Deprecated.Use BeanUtils.capitalize insteadstatic Class[]castArgumentsToClassArray(Object[] argTypes)static ObjectchooseEmptyMethodParams(FastArray methods)static ObjectchooseMostGeneralMethodWith1NullParam(FastArray methods)Deprecated.static booleancontainsMatchingMethod(List list, MetaMethod method)static StringconvertPropertyName(String prop)Converts a String into a standard property name.static Class[]convertToTypeArray(Object[] args)param instance array to the type arraystatic GroovyRuntimeExceptioncreateExceptionText(String init, MetaMethod method, Object object, Object[] args, Throwable reason, boolean setReason)static voiddoSetMetaClass(Object self, MetaClass mc)Sets the meta class for an object, by delegating to the appropriateDefaultGroovyMethodshelper method.protected static StringgetClassName(Object object)static ClosuregetMethodPointer(Object object, String methodName)Returns a callable object for the given method name on the object.static booleanisAssignableFrom(Class classToTransformTo, Class classToTransformFrom)static booleanisGenericSetMethod(MetaMethod method)protected static booleanisSuperclass(Class clazz, Class superclass)static voidlogMethodCall(Object object, String methodName, Object[] arguments)static ObjectmakeArray(Object obj, Class secondary, int length)static ObjectmakeCommonArray(Object[] arguments, int offset, Class fallback)protected static StringnormalizedValue(Object argument)static booleanparametersAreCompatible(Class[] arguments, Class[] parameters)static booleansameClass(Class[] params, Object arg)static booleansameClasses(Class[] params)static booleansameClasses(Class[] params, Object arg1)static booleansameClasses(Class[] params, Object[] arguments)static booleansameClasses(Class[] params, Object[] arguments, boolean weakNullCheck)static booleansameClasses(Class[] params, Object arg1, Object arg2)static booleansameClasses(Class[] params, Object arg1, Object arg2, Object arg3)static booleansameClasses(Class[] params, Object arg1, Object arg2, Object arg3, Object arg4)protected static StringshortName(Object object)static voidunwrap(Object[] arguments)static Class[]wrap(Class[] classes)
 
- 
- 
- 
Method Detail- 
accessibleToConstructorpublic static boolean accessibleToConstructor(Class at, Constructor constructor) 
 - 
asPrimitiveArraypublic static Object asPrimitiveArray(List list, Class parameterType) - Parameters:
- list- the original list
- parameterType- the resulting array type
- Returns:
- the constructed array
 
 - 
calculateParameterDistancepublic static long calculateParameterDistance(Class[] arguments, ParameterTypes pt) 
 - 
capitalize@Deprecated public static String capitalize(String property) Deprecated.Use BeanUtils.capitalize instead
 - 
chooseEmptyMethodParamspublic static Object chooseEmptyMethodParams(FastArray methods) - Parameters:
- methods- the methods to choose from
- Returns:
- the method with 1 parameter which takes the most general type of object (e.g. Object)
 
 - 
chooseMostGeneralMethodWith1NullParam@Deprecated public static Object chooseMostGeneralMethodWith1NullParam(FastArray methods) Deprecated.Warning: this method does not choose properly if multiple methods with the same distance are encountered- Parameters:
- methods- the methods to choose from
- Returns:
- the method with 1 parameter which takes the most general type of object (e.g. Object) ignoring primitive types
 
 - 
containsMatchingMethodpublic static boolean containsMatchingMethod(List list, MetaMethod method) - Parameters:
- list- a list of MetaMethods
- method- the MetaMethod of interest
- Returns:
- true if a method of the same matching prototype was found in the list
 
 - 
convertToTypeArraypublic static Class[] convertToTypeArray(Object[] args) param instance array to the type array- Parameters:
- args- the arguments
- Returns:
- the types of the arguments
 
 - 
makeCommonArraypublic static Object makeCommonArray(Object[] arguments, int offset, Class fallback) 
 - 
createExceptionTextpublic static GroovyRuntimeException createExceptionText(String init, MetaMethod method, Object object, Object[] args, Throwable reason, boolean setReason) 
 - 
getMethodPointerpublic static Closure getMethodPointer(Object object, String methodName) Returns a callable object for the given method name on the object. The object acts like a Closure in that it can be called, like a closure and passed around - though really its a method pointer, not a closure per se.- Parameters:
- object- the object containing the method
- methodName- the method of interest
- Returns:
- the resulting closure-like method pointer
 
 - 
isAssignableFrompublic static boolean isAssignableFrom(Class classToTransformTo, Class classToTransformFrom) 
 - 
isGenericSetMethodpublic static boolean isGenericSetMethod(MetaMethod method) 
 - 
parametersAreCompatiblepublic static boolean parametersAreCompatible(Class[] arguments, Class[] parameters) 
 - 
logMethodCallpublic static void logMethodCall(Object object, String methodName, Object[] arguments) 
 - 
sameClassespublic static boolean sameClasses(Class[] params, Object[] arguments, boolean weakNullCheck) 
 - 
sameClassespublic static boolean sameClasses(Class[] params) 
 - 
sameClassespublic static boolean sameClasses(Class[] params, Object arg1, Object arg2, Object arg3) 
 - 
sameClassespublic static boolean sameClasses(Class[] params, Object arg1, Object arg2, Object arg3, Object arg4) 
 - 
unwrappublic static void unwrap(Object[] arguments) 
 - 
doSetMetaClasspublic static void doSetMetaClass(Object self, MetaClass mc) Sets the meta class for an object, by delegating to the appropriateDefaultGroovyMethodshelper method. This method was introduced as a breaking change in 2.0 to solve rare cases of stack overflow. See GROOVY-5285. The method is named doSetMetaClass in order to prevent misusages. Do not use this method directly unless you know what you do.- Parameters:
- self- the object for which to set the meta class
- mc- the metaclass
 
 
- 
 
-