public class MetaClassHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.Object[] |
ARRAY_WITH_NULL |
static java.lang.Object[] |
EMPTY_ARRAY |
static java.lang.Class[] |
EMPTY_CLASS_ARRAY |
static java.lang.Class[] |
EMPTY_TYPE_ARRAY |
protected static java.util.logging.Logger |
LOG |
Constructor and Description |
---|
MetaClassHelper() |
Modifier and Type | Method and Description |
---|---|
static boolean |
accessibleToConstructor(java.lang.Class at,
java.lang.reflect.Constructor constructor) |
static java.lang.Object |
asPrimitiveArray(java.util.List list,
java.lang.Class parameterType) |
static java.lang.Object[] |
asWrapperArray(java.lang.Object parameters,
java.lang.Class componentType) |
static long |
calculateParameterDistance(java.lang.Class[] arguments,
ParameterTypes pt) |
static java.lang.String |
capitalize(java.lang.String property)
This is the complement to the java.beans.Introspector.decapitalize(String) method.
|
static java.lang.Class[] |
castArgumentsToClassArray(java.lang.Object[] argTypes) |
static java.lang.Object |
chooseEmptyMethodParams(FastArray methods) |
static java.lang.Object |
chooseMostGeneralMethodWith1NullParam(FastArray methods)
Deprecated.
|
static boolean |
containsMatchingMethod(java.util.List list,
MetaMethod method) |
static java.lang.String |
convertPropertyName(java.lang.String prop)
Converts a String into a standard property name.
|
static java.lang.Class[] |
convertToTypeArray(java.lang.Object[] args)
param instance array to the type array
|
static GroovyRuntimeException |
createExceptionText(java.lang.String init,
MetaMethod method,
java.lang.Object object,
java.lang.Object[] args,
java.lang.Throwable reason,
boolean setReason) |
static void |
doSetMetaClass(java.lang.Object self,
MetaClass mc)
Sets the meta class for an object, by delegating to the appropriate
DefaultGroovyMethods helper method. |
protected static java.lang.String |
getClassName(java.lang.Object object) |
static Closure |
getMethodPointer(java.lang.Object object,
java.lang.String methodName)
Returns a callable object for the given method name on the object.
|
static boolean |
isAssignableFrom(java.lang.Class classToTransformTo,
java.lang.Class classToTransformFrom) |
static boolean |
isGenericSetMethod(MetaMethod method) |
protected static boolean |
isSuperclass(java.lang.Class clazz,
java.lang.Class superclass) |
static void |
logMethodCall(java.lang.Object object,
java.lang.String methodName,
java.lang.Object[] arguments) |
static java.lang.Object |
makeArray(java.lang.Object obj,
java.lang.Class secondary,
int length) |
static java.lang.Object |
makeCommonArray(java.lang.Object[] arguments,
int offset,
java.lang.Class fallback) |
protected static java.lang.String |
normalizedValue(java.lang.Object argument) |
static boolean |
parametersAreCompatible(java.lang.Class[] arguments,
java.lang.Class[] parameters) |
static boolean |
sameClass(java.lang.Class[] params,
java.lang.Object arg) |
static boolean |
sameClasses(java.lang.Class[] params) |
static boolean |
sameClasses(java.lang.Class[] params,
java.lang.Object arg1) |
static boolean |
sameClasses(java.lang.Class[] params,
java.lang.Object[] arguments) |
static boolean |
sameClasses(java.lang.Class[] params,
java.lang.Object[] arguments,
boolean weakNullCheck) |
static boolean |
sameClasses(java.lang.Class[] params,
java.lang.Object arg1,
java.lang.Object arg2) |
static boolean |
sameClasses(java.lang.Class[] params,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3) |
static boolean |
sameClasses(java.lang.Class[] params,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3,
java.lang.Object arg4) |
protected static java.lang.String |
shortName(java.lang.Object object) |
static void |
unwrap(java.lang.Object[] arguments) |
static java.lang.Class[] |
wrap(java.lang.Class[] classes) |
public static final java.lang.Object[] EMPTY_ARRAY
public static final java.lang.Class[] EMPTY_TYPE_ARRAY
public static final java.lang.Object[] ARRAY_WITH_NULL
protected static final java.util.logging.Logger LOG
public static final java.lang.Class[] EMPTY_CLASS_ARRAY
public static boolean accessibleToConstructor(java.lang.Class at, java.lang.reflect.Constructor constructor)
public static java.lang.Object[] asWrapperArray(java.lang.Object parameters, java.lang.Class componentType)
public static java.lang.Object asPrimitiveArray(java.util.List list, java.lang.Class parameterType)
list
- the original listparameterType
- the resulting array typepublic static long calculateParameterDistance(java.lang.Class[] arguments, ParameterTypes pt)
public static java.lang.String capitalize(java.lang.String property)
property
- the property name to capitalizepublic static java.lang.Object chooseEmptyMethodParams(FastArray methods)
methods
- the methods to choose from@Deprecated public static java.lang.Object chooseMostGeneralMethodWith1NullParam(FastArray methods)
methods
- the methods to choose frompublic static boolean containsMatchingMethod(java.util.List list, MetaMethod method)
list
- a list of MetaMethodsmethod
- the MetaMethod of interestpublic static java.lang.Class[] convertToTypeArray(java.lang.Object[] args)
args
- the argumentspublic static java.lang.Object makeCommonArray(java.lang.Object[] arguments, int offset, java.lang.Class fallback)
public static java.lang.Object makeArray(java.lang.Object obj, java.lang.Class secondary, int length)
public static GroovyRuntimeException createExceptionText(java.lang.String init, MetaMethod method, java.lang.Object object, java.lang.Object[] args, java.lang.Throwable reason, boolean setReason)
protected static java.lang.String getClassName(java.lang.Object object)
public static Closure getMethodPointer(java.lang.Object object, java.lang.String methodName)
object
- the object containing the methodmethodName
- the method of interestpublic static boolean isAssignableFrom(java.lang.Class classToTransformTo, java.lang.Class classToTransformFrom)
public static boolean isGenericSetMethod(MetaMethod method)
protected static boolean isSuperclass(java.lang.Class clazz, java.lang.Class superclass)
public static boolean parametersAreCompatible(java.lang.Class[] arguments, java.lang.Class[] parameters)
public static void logMethodCall(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)
protected static java.lang.String normalizedValue(java.lang.Object argument)
protected static java.lang.String shortName(java.lang.Object object)
public static java.lang.Class[] wrap(java.lang.Class[] classes)
public static boolean sameClasses(java.lang.Class[] params, java.lang.Object[] arguments, boolean weakNullCheck)
public static boolean sameClasses(java.lang.Class[] params, java.lang.Object[] arguments)
public static boolean sameClasses(java.lang.Class[] params)
public static boolean sameClasses(java.lang.Class[] params, java.lang.Object arg1)
public static boolean sameClasses(java.lang.Class[] params, java.lang.Object arg1, java.lang.Object arg2)
public static boolean sameClasses(java.lang.Class[] params, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
public static boolean sameClasses(java.lang.Class[] params, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
public static boolean sameClass(java.lang.Class[] params, java.lang.Object arg)
public static java.lang.Class[] castArgumentsToClassArray(java.lang.Object[] argTypes)
public static void unwrap(java.lang.Object[] arguments)
public static void doSetMetaClass(java.lang.Object self, MetaClass mc)
DefaultGroovyMethods
helper 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.self
- the object for which to set the meta classmc
- the metaclasspublic static java.lang.String convertPropertyName(java.lang.String prop)
prop
- the original name