Search in sources :

Example 1 with NewStaticMetaMethod

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

the class MetaClassImpl method addNewStaticMethod.

/**
     *Adds a static method to this metaclass.
     *
     * @param method The method to be added
     */
public void addNewStaticMethod(Method method) {
    final CachedMethod cachedMethod = CachedMethod.find(method);
    NewStaticMetaMethod newMethod = new NewStaticMetaMethod(cachedMethod);
    final CachedClass declaringClass = newMethod.getDeclaringClass();
    addNewStaticMethodToIndex(newMethod, metaMethodIndex.getHeader(declaringClass.getTheClass()));
}
Also used : NewStaticMetaMethod(org.codehaus.groovy.runtime.metaclass.NewStaticMetaMethod) CachedMethod(org.codehaus.groovy.reflection.CachedMethod) CachedClass(org.codehaus.groovy.reflection.CachedClass)

Example 2 with NewStaticMetaMethod

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

the class SimpleExtensionModule method createMetaMethods.

private void createMetaMethods(final Class extensionClass, final List<MetaMethod> metaMethods, final boolean isStatic) {
    CachedClass cachedClass = ReflectionCache.getCachedClass(extensionClass);
    CachedMethod[] methods = cachedClass.getMethods();
    for (CachedMethod method : methods) {
        if (method.isStatic() && method.isPublic() && method.getParamsCount() > 0) {
            // an extension method is found
            metaMethods.add(isStatic ? new NewStaticMetaMethod(method) : new NewInstanceMetaMethod(method));
        }
    }
}
Also used : NewInstanceMetaMethod(org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod) NewStaticMetaMethod(org.codehaus.groovy.runtime.metaclass.NewStaticMetaMethod) CachedMethod(org.codehaus.groovy.reflection.CachedMethod) CachedClass(org.codehaus.groovy.reflection.CachedClass)

Example 3 with NewStaticMetaMethod

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

the class MetaClassImpl method addNewStaticMethod.

/**
     *Adds a static method to this metaclass.
     *
     * @param method The method to be added
     */
public void addNewStaticMethod(Method method) {
    final CachedMethod cachedMethod = CachedMethod.find(method);
    NewStaticMetaMethod newMethod = new NewStaticMetaMethod(cachedMethod);
    final CachedClass declaringClass = newMethod.getDeclaringClass();
    addNewStaticMethodToIndex(newMethod, metaMethodIndex.getHeader(declaringClass.getTheClass()));
}
Also used : NewStaticMetaMethod(org.codehaus.groovy.runtime.metaclass.NewStaticMetaMethod) CachedMethod(org.codehaus.groovy.reflection.CachedMethod) CachedClass(org.codehaus.groovy.reflection.CachedClass)

Example 4 with NewStaticMetaMethod

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

the class SimpleExtensionModule method createMetaMethods.

private static void createMetaMethods(final Class extensionClass, final List<MetaMethod> metaMethods, final boolean isStatic) {
    CachedClass cachedClass = ReflectionCache.getCachedClass(extensionClass);
    CachedMethod[] methods = cachedClass.getMethods();
    for (CachedMethod method : methods) {
        if (method.isStatic() && method.isPublic() && method.getParamsCount() > 0) {
            // an extension method is found
            metaMethods.add(isStatic ? new NewStaticMetaMethod(method) : new NewInstanceMetaMethod(method));
        }
    }
}
Also used : NewInstanceMetaMethod(org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod) NewStaticMetaMethod(org.codehaus.groovy.runtime.metaclass.NewStaticMetaMethod) CachedMethod(org.codehaus.groovy.reflection.CachedMethod) CachedClass(org.codehaus.groovy.reflection.CachedClass)

Aggregations

CachedClass (org.codehaus.groovy.reflection.CachedClass)4 CachedMethod (org.codehaus.groovy.reflection.CachedMethod)4 NewStaticMetaMethod (org.codehaus.groovy.runtime.metaclass.NewStaticMetaMethod)4 NewInstanceMetaMethod (org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod)2