Search in sources :

Example 1 with TransformMetaMethod

use of org.codehaus.groovy.runtime.metaclass.TransformMetaMethod in project groovy-core by groovy.

the class MetaClassImpl method tryListParamMetaMethod.

private MetaMethod tryListParamMetaMethod(Class sender, String methodName, boolean isCallToSuper, Object[] arguments) {
    MetaMethod method = null;
    if (arguments.length == 1 && arguments[0] instanceof List) {
        Object[] newArguments = ((List) arguments[0]).toArray();
        method = getMethodWithCaching(sender, methodName, newArguments, isCallToSuper);
        if (method != null) {
            method = new TransformMetaMethod(method) {

                public Object invoke(Object object, Object[] arguments) {
                    Object firstArgument = arguments[0];
                    List list = (List) firstArgument;
                    arguments = list.toArray();
                    return super.invoke(object, arguments);
                }
            };
        }
    }
    return method;
}
Also used : NewInstanceMetaMethod(org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod) NewMetaMethod(org.codehaus.groovy.runtime.metaclass.NewMetaMethod) MixinInstanceMetaMethod(org.codehaus.groovy.runtime.metaclass.MixinInstanceMetaMethod) NewStaticMetaMethod(org.codehaus.groovy.runtime.metaclass.NewStaticMetaMethod) GeneratedMetaMethod(org.codehaus.groovy.reflection.GeneratedMetaMethod) ClosureMetaMethod(org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod) TransformMetaMethod(org.codehaus.groovy.runtime.metaclass.TransformMetaMethod) TransformMetaMethod(org.codehaus.groovy.runtime.metaclass.TransformMetaMethod)

Example 2 with TransformMetaMethod

use of org.codehaus.groovy.runtime.metaclass.TransformMetaMethod in project groovy by apache.

the class MetaClassImpl method tryListParamMetaMethod.

private MetaMethod tryListParamMetaMethod(Class sender, String methodName, boolean isCallToSuper, Object[] arguments) {
    MetaMethod method = null;
    if (arguments.length == 1 && arguments[0] instanceof List) {
        Object[] newArguments = ((List) arguments[0]).toArray();
        method = getMethodWithCaching(sender, methodName, newArguments, isCallToSuper);
        if (method != null) {
            method = new TransformMetaMethod(method) {

                public Object invoke(Object object, Object[] arguments) {
                    Object firstArgument = arguments[0];
                    List list = (List) firstArgument;
                    arguments = list.toArray();
                    return super.invoke(object, arguments);
                }
            };
        }
    }
    return method;
}
Also used : NewInstanceMetaMethod(org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod) NewMetaMethod(org.codehaus.groovy.runtime.metaclass.NewMetaMethod) MixinInstanceMetaMethod(org.codehaus.groovy.runtime.metaclass.MixinInstanceMetaMethod) NewStaticMetaMethod(org.codehaus.groovy.runtime.metaclass.NewStaticMetaMethod) GeneratedMetaMethod(org.codehaus.groovy.reflection.GeneratedMetaMethod) ClosureMetaMethod(org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod) TransformMetaMethod(org.codehaus.groovy.runtime.metaclass.TransformMetaMethod) TransformMetaMethod(org.codehaus.groovy.runtime.metaclass.TransformMetaMethod)

Aggregations

GeneratedMetaMethod (org.codehaus.groovy.reflection.GeneratedMetaMethod)2 ClosureMetaMethod (org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod)2 MixinInstanceMetaMethod (org.codehaus.groovy.runtime.metaclass.MixinInstanceMetaMethod)2 NewInstanceMetaMethod (org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod)2 NewMetaMethod (org.codehaus.groovy.runtime.metaclass.NewMetaMethod)2 NewStaticMetaMethod (org.codehaus.groovy.runtime.metaclass.NewStaticMetaMethod)2 TransformMetaMethod (org.codehaus.groovy.runtime.metaclass.TransformMetaMethod)2