Package org.codehaus.groovy.runtime
Class MetaClassHelper
java.lang.Object
org.codehaus.groovy.runtime.MetaClassHelper
- Author:
- John Wilson, Jochen Theodorou
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
accessibleToConstructor
(Class at, Constructor constructor) static Object
asPrimitiveArray
(List list, Class parameterType) static Object[]
asWrapperArray
(Object parameters, Class componentType) static long
calculateParameterDistance
(Class[] arguments, ParameterTypes pt) static String
capitalize
(String property) This is the complement to the java.beans.Introspector.decapitalize(String) method.static Class[]
castArgumentsToClassArray
(Object[] argTypes) static Object
chooseEmptyMethodParams
(FastArray methods) static Object
static boolean
containsMatchingMethod
(List list, MetaMethod method) static Class[]
convertToTypeArray
(Object[] args) param instance array to the type arraystatic GroovyRuntimeException
createExceptionText
(String init, MetaMethod method, Object object, Object[] args, Throwable reason, boolean setReason) protected static String
getClassName
(Object object) static Closure
getMethodPointer
(Object object, String methodName) Returns a callable object for the given method name on the object.static boolean
isAssignableFrom
(Class classToTransformTo, Class classToTransformFrom) static boolean
isGenericSetMethod
(MetaMethod method) protected static boolean
isSuperclass
(Class clazz, Class superclass) static void
logMethodCall
(Object object, String methodName, Object[] arguments) static Object
static Object
makeCommonArray
(Object[] arguments, int offset, Class fallback) protected static String
normalizedValue
(Object argument) static boolean
parametersAreCompatible
(Class[] arguments, Class[] parameters) static boolean
static boolean
sameClasses
(Class[] params) static boolean
sameClasses
(Class[] params, Object arg1) static boolean
sameClasses
(Class[] params, Object[] arguments) static boolean
sameClasses
(Class[] params, Object[] arguments, boolean weakNullCheck) static boolean
sameClasses
(Class[] params, Object arg1, Object arg2) static boolean
sameClasses
(Class[] params, Object arg1, Object arg2, Object arg3) static boolean
protected static String
static void
static Class[]
-
Field Details
-
EMPTY_ARRAY
-
EMPTY_TYPE_ARRAY
-
ARRAY_WITH_NULL
-
LOG
-
EMPTY_CLASS_ARRAY
-
-
Constructor Details
-
MetaClassHelper
public MetaClassHelper()
-
-
Method Details
-
accessibleToConstructor
-
asWrapperArray
-
asPrimitiveArray
- Parameters:
list
- the original listparameterType
- the resulting array type- Returns:
- the constructed array
-
calculateParameterDistance
-
capitalize
This is the complement to the java.beans.Introspector.decapitalize(String) method. We handle names that begin with an initial lowerCase followed by upperCase specially (which is to make no change). See GROOVY-3211.- Parameters:
property
- the property name to capitalize- Returns:
- the name capitalized, except when we don't
-
chooseEmptyMethodParams
- 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
- 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
-
containsMatchingMethod
- Parameters:
list
- a list of MetaMethodsmethod
- the MetaMethod of interest- Returns:
- true if a method of the same matching prototype was found in the list
-
convertToTypeArray
param instance array to the type array- Parameters:
args
- the arguments- Returns:
- the types of the arguments
-
makeCommonArray
-
makeArray
-
createExceptionText
public static GroovyRuntimeException createExceptionText(String init, MetaMethod method, Object object, Object[] args, Throwable reason, boolean setReason) -
getClassName
-
getMethodPointer
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 methodmethodName
- the method of interest- Returns:
- the resulting closure-like method pointer
-
isAssignableFrom
-
isGenericSetMethod
-
isSuperclass
-
parametersAreCompatible
-
logMethodCall
-
normalizedValue
-
shortName
-
wrap
-
sameClasses
-
sameClasses
-
sameClasses
-
sameClasses
-
sameClasses
-
sameClasses
-
sameClasses
-
sameClass
-
castArgumentsToClassArray
-
unwrap
-