use of org.codehaus.groovy.reflection.CachedMethod 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()));
}
use of org.codehaus.groovy.reflection.CachedMethod in project groovy by apache.
the class MetaClassImpl method applyPropertyDescriptors.
protected void applyPropertyDescriptors(PropertyDescriptor[] propertyDescriptors) {
// MetaBeanProperty objects
for (PropertyDescriptor pd : propertyDescriptors) {
// which is not a valid property)
if (pd.getPropertyType() == null)
continue;
// get the getter method
Method method = pd.getReadMethod();
MetaMethod getter;
if (method != null) {
CachedMethod cachedGetter = CachedMethod.find(method);
getter = cachedGetter == null ? null : findMethod(cachedGetter);
} else {
getter = null;
}
// get the setter method
MetaMethod setter;
method = pd.getWriteMethod();
if (method != null) {
CachedMethod cachedSetter = CachedMethod.find(method);
setter = cachedSetter == null ? null : findMethod(cachedSetter);
} else {
setter = null;
}
// now create the MetaProperty object
MetaBeanProperty mp = new MetaBeanProperty(pd.getName(), pd.getPropertyType(), getter, setter);
addMetaBeanProperty(mp);
}
}
use of org.codehaus.groovy.reflection.CachedMethod in project groovy-core by groovy.
the class A_GroovyReflector method doIt.
static void doIt() {
new A().protectedMethod();
try {
CachedMethod m = CachedMethod.find(A.class.getDeclaredMethod("protectedMethod", new Class[0]));
Object[] arguments = new Object[0];
m.setAccessible().invoke(new A(), arguments);
} catch (NoSuchMethodException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
}
}
use of org.codehaus.groovy.reflection.CachedMethod in project groovy-core by groovy.
the class MetaClassImpl method addNewInstanceMethod.
/**
*Adds an instance method to this metaclass.
*
* @param method The method to be added
*/
public void addNewInstanceMethod(Method method) {
final CachedMethod cachedMethod = CachedMethod.find(method);
NewInstanceMetaMethod newMethod = new NewInstanceMetaMethod(cachedMethod);
final CachedClass declaringClass = newMethod.getDeclaringClass();
addNewInstanceMethodToIndex(newMethod, metaMethodIndex.getHeader(declaringClass.getTheClass()));
}
use of org.codehaus.groovy.reflection.CachedMethod 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()));
}
Aggregations