1 package org.kohsuke.stapler; 2 3 import java.lang.reflect.Field ; 4 import java.lang.reflect.Method ; 5 import java.lang.reflect.Modifier ; 6 import java.util.ArrayList ; 7 import java.util.List ; 8 9 14 final class ClassDescriptor { 15 public final Class clazz; 16 public final FunctionList methods; 17 public final Field [] fields; 18 19 29 public ClassDescriptor(Class clazz, Class ... wrappers) { 30 this.clazz = clazz; 31 this.fields = clazz.getFields(); 32 33 List <Function> functions = new ArrayList <Function>(); 35 for (Method m : clazz.getMethods()) { 36 functions.add(new Function.InstanceFunction(m).protectBy(m)); 37 } 38 if(wrappers!=null) { 39 for (Class w : wrappers) { 40 for (Method m : w.getMethods()) { 41 if(!Modifier.isStatic(m.getModifiers())) 42 continue; 43 Class <?>[] p = m.getParameterTypes(); 44 if(p.length==0) 45 continue; 46 if(p[0].isAssignableFrom(clazz)) 47 continue; 48 functions.add(new Function.StaticFunction(m).protectBy(m)); 49 } 50 } 51 } 52 this.methods = new FunctionList(functions); 53 } 54 } 55 | Popular Tags |