Package: org.codehaus.groovy.runtime

## [Java] Class MetaClassHelper

- org.codehaus.groovy.runtime.MetaClassHelper

-     public class MetaClassHelper
      extends Object

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static Object[]` | `ARRAY_WITH_NULL` |
    `static Object[]` | `EMPTY_ARRAY` |
    `static Class[]` | `EMPTY_CLASS_ARRAY` |
    `static Class[]` | `EMPTY_TYPE_ARRAY` |

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static boolean` | `accessibleToConstructor(Class at, Constructor constructor)`
    `` | `public static Object` | `asPrimitiveArray(List list, Class parameterType)` Parameters: `list` - the original list
    `` | `public static Object[]` | `asWrapperArray(Object parameters, Class componentType)`
    `` | `public static long` | `calculateParameterDistance(Class[] arguments, ParameterTypes pt)`
    `` | `public static String` | `capitalize(String property)` deprecated: Use BeanUtils.capitalize instead
    `` | `public static Class[]` | `castArgumentsToClassArray(Object[] arguments)` Parameters: `arguments` - an array of classes, values, or nulls
    `` | `public static Object` | `chooseEmptyMethodParams(FastArray methods)` Parameters: `methods` - the methods to choose from
    `` | `public static Object` | `chooseMostGeneralMethodWith1NullParam(FastArray methods)` Warning: this method does not choose properly if multiple methods with the same distance are encountered
    `` | `public static boolean` | `containsMatchingMethod(List list, MetaMethod method)` Parameters: `list` - a list of MetaMethods
    `` | `public static String` | `convertPropertyName(String prop)` Converts a String into a standard property name.
    `` | `public static Class[]` | `convertToTypeArray(Object[] arguments)` Converts array of values (incl.
    `` | `public static GroovyRuntimeException` | `createExceptionText(String init, MetaMethod method, Object object, Object[] args, Throwable reason, boolean setReason)`
    `` | `public static void` | `doSetMetaClass(Object self, MetaClass mc)` Sets the metaclass for an object, by delegating to the appropriate DefaultGroovyMethods helper method.
    `` | `protected static String` | `getClassName(Object object)`
    `` | `public static Closure` | `getMethodPointer(Object object, String methodName)` Returns a callable object for the given method name on the object.
    `` | `public static boolean` | `isAssignableFrom(Class classToTransformTo, Class classToTransformFrom)`
    `` | `protected static boolean` | `isSuperclass(Class clazz, Class superclass)`
    `` | `public static void` | `logMethodCall(Object object, String methodName, Object[] arguments)`
    `` | `public static Object` | `makeArray(Object obj, Class secondary, int length)`
    `` | `public static Object` | `makeCommonArray(Object[] arguments, int offset, Class fallback)`
    `` | `public static Object` | `normalizeBoxedReturn(Object value, Class<?> returnType)` Re-normalizes a reflectively boxed primitive return value through the `valueOf` caches.
    `` | `protected static String` | `normalizedValue(Object argument)`
    `` | `public static boolean` | `parametersAreCompatible(Class[] arguments, Class[] parameters)`
    `` | `public static boolean` | `sameClass(Class[] params, Object arg)`
    `` | `public static boolean` | `sameClasses(Class[] params, Object[] arguments, boolean weakNullCheck)`
    `` | `public static boolean` | `sameClasses(Class[] params, Object[] arguments)`
    `` | `public static boolean` | `sameClasses(Class[] params)`
    `` | `public static boolean` | `sameClasses(Class[] params, Object arg1)`
    `` | `public static boolean` | `sameClasses(Class[] params, Object arg1, Object arg2)`
    `` | `public static boolean` | `sameClasses(Class[] params, Object arg1, Object arg2, Object arg3)`
    `` | `public static boolean` | `sameClasses(Class[] params, Object arg1, Object arg2, Object arg3, Object arg4)`
    `` | `protected static String` | `shortName(Object object)`
    `` | `public static void` | `unwrap(Object[] arguments)`
    `` | `public static Class[]` | `wrap(Class[] classes)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### public static final Object[] ARRAY_WITH_NULL

    - #### public static final Object[] EMPTY_ARRAY

    - #### public static final Class[] EMPTY_CLASS_ARRAY

    - #### public static final Class[] EMPTY_TYPE_ARRAY

  - ### Method Detail

    - #### public static boolean accessibleToConstructor(Class at, Constructor constructor)

    - #### public static Object asPrimitiveArray(List list, Class parameterType)

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

    - #### public static Object[] asWrapperArray(Object parameters, Class componentType)

    - #### public static long calculateParameterDistance(Class[] arguments, ParameterTypes pt)

    - #### @Deprecated(forRemoval = true, since = "3.0.0")
      public static String capitalize(String property)

      deprecated:
        Use BeanUtils.capitalize instead

    - #### public static Class[] castArgumentsToClassArray(Object[] arguments)

      Parameters:
        `arguments` - an array of classes, values, or nulls

    - #### public 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)

    - #### @Deprecated
      public static Object chooseMostGeneralMethodWith1NullParam(FastArray methods)

      Warning: this method does not choose properly if multiple methods with the same distance are encountered

      deprecated:
      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

    - #### public 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

    - #### public static String convertPropertyName(String prop)

      Converts a String into a standard property name.

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

    - #### public static Class[] convertToTypeArray(Object[] arguments)

      Converts array of values (incl. `null`) to their respective types.

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

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

    - #### public static void doSetMetaClass(Object self, MetaClass mc)

      Sets the metaclass 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 misuses. Do not use this method directly unless you know what you do.

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

    - #### protected static String getClassName(Object object)

    - #### public 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 it's 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

    - #### public static boolean isAssignableFrom(Class classToTransformTo, Class classToTransformFrom)

    - #### protected static boolean isSuperclass(Class clazz, Class superclass)

    - #### public static void logMethodCall(Object object, String methodName, Object[] arguments)

    - #### public static Object makeArray(Object obj, Class secondary, int length)

    - #### public static Object makeCommonArray(Object[] arguments, int offset, Class fallback)

    - #### public static Object normalizeBoxedReturn(Object value, Class<?> returnType)

      Re-normalizes a reflectively boxed primitive return value through the `valueOf` caches. Method.invoke boxes primitive returns with fresh instances, unlike MethodHandle-based and generated-bytecode invocation, which box through the caches; without normalization, reference identity (`===`) of primitive returns would differ between dispatch paths (GROOVY-12140).

      Parameters:
        `value` - the reflectively boxed return value (may be `null`)
        `returnType` - the declared return type of the invoked method
      Returns:
        the cache-normalized value
      Since:
        6.0.0

    - #### protected static String normalizedValue(Object argument)

    - #### public static boolean parametersAreCompatible(Class[] arguments, Class[] parameters)

    - #### public static boolean sameClass(Class[] params, Object arg)

    - #### public static boolean sameClasses(Class[] params, Object[] arguments, boolean weakNullCheck)

    - #### public static boolean sameClasses(Class[] params, Object[] arguments)

    - #### public static boolean sameClasses(Class[] params)

    - #### public static boolean sameClasses(Class[] params, Object arg1)

    - #### public static boolean sameClasses(Class[] params, Object arg1, Object arg2)

    - #### public static boolean sameClasses(Class[] params, Object arg1, Object arg2, Object arg3)

    - #### public static boolean sameClasses(Class[] params, Object arg1, Object arg2, Object arg3, Object arg4)

    - #### protected static String shortName(Object object)

    - #### public static void unwrap(Object[] arguments)

    - #### public static Class[] wrap(Class[] classes)