org.codehaus.groovy.runtime

## Class MetaClassHelper

- java.lang.Object
- - org.codehaus.groovy.runtime.MetaClassHelper

    public class MetaClassHelper
    extends java.lang.Object

Author:
  John Wilson, Jochen Theodorou

### Field Summary

Fields
`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 Summary

Constructors
Constructor and Description
`MetaClassHelper()`

### Method Summary

All Methods Static Methods Concrete Methods Deprecated Methods
`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)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### EMPTY_ARRAY

    public static final java.lang.Object[] EMPTY_ARRAY

#### EMPTY_TYPE_ARRAY

    public static final java.lang.Class[] EMPTY_TYPE_ARRAY

#### ARRAY_WITH_NULL

    public static final java.lang.Object[] ARRAY_WITH_NULL

#### LOG

    protected static final java.util.logging.Logger LOG

#### EMPTY_CLASS_ARRAY

    public static final java.lang.Class[] EMPTY_CLASS_ARRAY

### Constructor Detail

#### MetaClassHelper

    public MetaClassHelper()

### Method Detail

#### accessibleToConstructor

    public static boolean accessibleToConstructor(java.lang.Class at,
                                                  java.lang.reflect.Constructor constructor)

#### asWrapperArray

    public static java.lang.Object[] asWrapperArray(java.lang.Object parameters,
                                                    java.lang.Class componentType)

#### asPrimitiveArray

    public static java.lang.Object asPrimitiveArray(java.util.List list,
                                                    java.lang.Class parameterType)

Parameters:
  `list` - the original list
  `parameterType` - the resulting array type
Returns:
  the constructed array

#### calculateParameterDistance

    public static long calculateParameterDistance(java.lang.Class[] arguments,
                                                  ParameterTypes pt)

#### capitalize

    public static java.lang.String capitalize(java.lang.String property)

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

    public static java.lang.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 java.lang.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

#### containsMatchingMethod

    public static boolean containsMatchingMethod(java.util.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

#### convertToTypeArray

    public static java.lang.Class[] convertToTypeArray(java.lang.Object[] args)

param instance array to the type array

Parameters:
  `args` - the arguments
Returns:
  the types of the arguments

#### makeCommonArray

    public static java.lang.Object makeCommonArray(java.lang.Object[] arguments,
                                                   int offset,
                                                   java.lang.Class fallback)

#### makeArray

    public static java.lang.Object makeArray(java.lang.Object obj,
                                             java.lang.Class secondary,
                                             int length)

#### createExceptionText

    public static GroovyRuntimeException createExceptionText(java.lang.String init,
                                                             MetaMethod method,
                                                             java.lang.Object object,
                                                             java.lang.Object[] args,
                                                             java.lang.Throwable reason,
                                                             boolean setReason)

#### getClassName

    protected static java.lang.String getClassName(java.lang.Object object)

#### getMethodPointer

    public static Closure getMethodPointer(java.lang.Object object,
                                           java.lang.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

#### isAssignableFrom

    public static boolean isAssignableFrom(java.lang.Class classToTransformTo,
                                           java.lang.Class classToTransformFrom)

#### isGenericSetMethod

    public static boolean isGenericSetMethod(MetaMethod method)

#### isSuperclass

    protected static boolean isSuperclass(java.lang.Class clazz,
                                          java.lang.Class superclass)

#### parametersAreCompatible

    public static boolean parametersAreCompatible(java.lang.Class[] arguments,
                                                  java.lang.Class[] parameters)

#### logMethodCall

    public static void logMethodCall(java.lang.Object object,
                                     java.lang.String methodName,
                                     java.lang.Object[] arguments)

#### normalizedValue

    protected static java.lang.String normalizedValue(java.lang.Object argument)

#### shortName

    protected static java.lang.String shortName(java.lang.Object object)

#### wrap

    public static java.lang.Class[] wrap(java.lang.Class[] classes)

#### sameClasses

    public static boolean sameClasses(java.lang.Class[] params,
                                      java.lang.Object[] arguments,
                                      boolean weakNullCheck)

#### sameClasses

    public static boolean sameClasses(java.lang.Class[] params,
                                      java.lang.Object[] arguments)

#### sameClasses

    public static boolean sameClasses(java.lang.Class[] params)

#### sameClasses

    public static boolean sameClasses(java.lang.Class[] params,
                                      java.lang.Object arg1)

#### sameClasses

    public static boolean sameClasses(java.lang.Class[] params,
                                      java.lang.Object arg1,
                                      java.lang.Object arg2)

#### sameClasses

    public static boolean sameClasses(java.lang.Class[] params,
                                      java.lang.Object arg1,
                                      java.lang.Object arg2,
                                      java.lang.Object arg3)

#### sameClasses

    public static boolean sameClasses(java.lang.Class[] params,
                                      java.lang.Object arg1,
                                      java.lang.Object arg2,
                                      java.lang.Object arg3,
                                      java.lang.Object arg4)

#### sameClass

    public static boolean sameClass(java.lang.Class[] params,
                                    java.lang.Object arg)

#### castArgumentsToClassArray

    public static java.lang.Class[] castArgumentsToClassArray(java.lang.Object[] argTypes)

#### unwrap

    public static void unwrap(java.lang.Object[] arguments)

#### doSetMetaClass

    public static void doSetMetaClass(java.lang.Object self,
                                      MetaClass mc)

Sets the meta class for an object, by delegating to the appropriate `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.

Parameters:
  `self` - the object for which to set the meta class
  `mc` - the metaclass

#### convertPropertyName

    public static java.lang.String convertPropertyName(java.lang.String prop)

Converts a String into a standard property name.

Parameters:
  `prop` - the original name
Returns:
  the converted name