Groovy 1.7.0

## org.codehaus.groovy.runtime
Class MetaClassHelper

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

    class MetaClassHelper
    extends Object

author:
  John Wilson

author:
  Jochen Theodorou

Field Summary
`static Object[]` | `ARRAY_WITH_NULL`
`static Object[]` | `EMPTY_ARRAY`
`static Class[]` | `EMPTY_CLASS_ARRAY`
`static Class[]` | `EMPTY_TYPE_ARRAY`
`protected static Logger` | `LOG`

Constructor Summary
`MetaClassHelper()`

Method Summary
`static 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)` note: when shifting with 32 bit, you should only shift on a long.
`static String` | `capitalize(String property)` In general we want to match the signature that allows us to use as less arguments for the vargs part as possible.
`static Class[]` | `castArgumentsToClassArray(Object[] argTypes)`
`static Object` | `chooseEmptyMethodParams(FastArray methods)` object (e.g.
`static Object` | `chooseMostGeneralMethodWith1NullParam(FastArray methods)` object (e.g.
`static boolean` | `containsMatchingMethod(List list, MetaMethod method)` list
`static Class[]` | `convertToTypeArray(Object[] args)` param instance array to the type array
`static 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 claszz, Class superclass)`
`static void` | `logMethodCall(Object object, String methodName, Object[] arguments)`
`static Object` | `makeArray(Object obj, Class secondary, int length)`
`static Object` | `makeCommonArray(Object[] arguments, int offset, Class fallback)`
`protected static String` | `normalizedValue(Object argument)`
`static boolean` | `parametersAreCompatible(Class[] arguments, Class[] parameters)`
`static boolean` | `sameClass(Class[] params, Object arg)`
`static boolean` | `sameClasses(Class[] params, Object[] arguments, boolean weakNullCheck)`
`static boolean` | `sameClasses(Class[] params, Object[] arguments)`
`static boolean` | `sameClasses(Class[] params)`
`static boolean` | `sameClasses(Class[] params, Object arg1)`
`static boolean` | `sameClasses(Class[] params, Object arg1, Object arg2)`
`static boolean` | `sameClasses(Class[] params, Object arg1, Object arg2, Object arg3)`
`static boolean` | `sameClasses(Class[] params, Object arg1, Object arg2, Object arg3, Object arg4)`
`protected static String` | `shortName(Object object)`
`static void` | `unwrap(Object[] arguments)`
`static Class[]` | `wrap(Class[] classes)`

Methods inherited from class Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll

Field Detail

### ARRAY_WITH_NULL

    static final Object[] ARRAY_WITH_NULL

### EMPTY_ARRAY

    static final Object[] EMPTY_ARRAY

### EMPTY_CLASS_ARRAY

    static final Class[] EMPTY_CLASS_ARRAY

### EMPTY_TYPE_ARRAY

    static final Class[] EMPTY_TYPE_ARRAY

### LOG

    protected static final Logger LOG

Constructor Detail

### MetaClassHelper

    MetaClassHelper()

Method Detail

### accessibleToConstructor

    public static boolean accessibleToConstructor(Class at, Constructor constructor)

### asPrimitiveArray

    public static Object asPrimitiveArray(List list, Class parameterType)

  param:
    list the original list
  param:
    parameterType the resulting array type
  return:
    the constructed array

### asWrapperArray

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

### calculateParameterDistance

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

  note: when shifting with 32 bit, you should only shift on a long. If you do that with an int, then i==(i<<32), which means you loose the shift information

### capitalize

    public static String capitalize(String property)

  In general we want to match the signature that allows us to use as less arguments for the vargs part as possible. That means the longer signature usually wins if both signatures are vargs, while vargs looses always against a signature without vargs. A vs B : def foo(Object[] a) {1} -> case B def foo(a,b,Object[] c) {2} -> case A assert foo(new Object(),new Object()) == 2 --> A preferred over B A vs C : def foo(Object[] a) {1} -> case B def foo(a,b) {2} -> case C assert foo(new Object(),new Object()) == 2 --> C preferred over A A vs D : def foo(Object[] a) {1} -> case D def foo(a,Object[] b) {2} -> case A assert foo(new Object()) == 2 --> A preferred over D This gives C<A<B,D B vs C : def foo(Object[] a) {1} -> case B def foo(a,b) {2} -> case C assert foo(new Object(),new Object()) == 2 --> C preferred over B, matches C<A<B,D B vs D : def foo(Object[] a) {1} -> case B def foo(a,Object[] b) {2} -> case D assert foo(new Object(),new Object()) == 2 --> D preferred over B This gives C<A<D<B

### castArgumentsToClassArray

    public static Class[] castArgumentsToClassArray(Object[] argTypes)

### chooseEmptyMethodParams

    public static Object chooseEmptyMethodParams(FastArray methods)

  param:
    methods the methods to choose from
  return:
    the method with 1 parameter which takes the most general type of object (e.g. Object)

### chooseMostGeneralMethodWith1NullParam

    public static Object chooseMostGeneralMethodWith1NullParam(FastArray methods)

  param:
    methods the methods to choose from
  return:
    the method with 1 parameter which takes the most general type of object (e.g. Object) ignoring primitve types

### containsMatchingMethod

    public static boolean containsMatchingMethod(List list, MetaMethod method)

  param:
    list a list of MetaMethods
  param:
    method the MetaMethod of interest
  return:
    true if a method of the same matching prototype was found in the list

### convertToTypeArray

    public static Class[] convertToTypeArray(Object[] args)

  param instance array to the type array
  param:
    args the arguments
  return:
    the types of the arguments

### createExceptionText

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

### getClassName

    protected static String getClassName(Object object)

### getMethodPointer

    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 its a method pointer, not a closure per se.
  param:
    object the object containing the method
  param:
    methodName the method of interest
  return:
    the resulting closure-like method pointer

### isAssignableFrom

    public static boolean isAssignableFrom(Class classToTransformTo, Class classToTransformFrom)

### isGenericSetMethod

    public static boolean isGenericSetMethod(MetaMethod method)

### isSuperclass

    protected static boolean isSuperclass(Class claszz, Class superclass)

### logMethodCall

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

### makeArray

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

### makeCommonArray

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

### normalizedValue

    protected static String normalizedValue(Object argument)

### parametersAreCompatible

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

### sameClass

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

### sameClasses

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

### sameClasses

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

### sameClasses

    public static boolean sameClasses(Class[] params)

### sameClasses

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

### sameClasses

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

### sameClasses

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

### sameClasses

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

### shortName

    protected static String shortName(Object object)

### unwrap

    public static void unwrap(Object[] arguments)

### wrap

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

Copyright © 2003-2009 The Codehaus. All rights reserved.