protected ReflectMethod(ReflectClass reflectClass,Method method) { super(reflectClass,method); this.accessor = reflectClass.getAccessor(); this.reflectedMethod = method; this.accessorIndex = accessor == null ? -1 : accessor.getMethodIndex(method); this.initialize(); }
@Override public final ReflectAccessor createAccessor(Class<?> clazz) { if(strategy.canCreateAccessor(clazz)){ return doCreateAccessor(clazz); } return null; }
/** * create a new instance of the given class. */ public static <T> T newInstance(Class<T> clazz){ return ReflectClass.of(clazz).newInstance(); }
protected ReflectEnum(Class<?> enumClass){ this.reflectiveClass = ReflectClass.of(enumClass); this.initialize(); }
@Override public void setValue(Object bean, Object value) { m.invoke(o, value); } }
public MethodReflectValued(Object o, ReflectMethod m) { this.o = o; this.m = m; this.p = m.getParameters()[0]; }
@Override public Class<?> getType() { return p.getType(); }
/** * Invoke the specified {@link Method} against the supplied target object with no Args. The target object can * be <code>null</code> when invoking a static {@link Method}. * * @param method the method to invoke * @param target the target object to invoke the method on * @return the invocation result, if any * @see #invokeMethod(java.lang.reflect.Method, Object, Object[]) */ public static Object invokeMethod(Method method, Object target) { return invokeMethod(method, target, Arrays2.EMPTY_OBJECT_ARRAY); }
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { // exclude synthetic + bridged && static class initialization if (!isSyntheticOrBridged(access) && !STATIC_CLASS_INIT.equals(name)) { return new LocalVariableTableVisitor(clazz, memberMap, name, desc, isStatic(access)); } return null; }
protected ReflectClass(Class<?> clazz){ this.clazz = clazz; this.accessor = Reflection.factory().createAccessor(this.clazz); this.innerClass = Classes.isInnerClass(clazz); this.initialize(); }
private void createFields(){ List<ReflectField> fieldList = new ArrayList<ReflectField>(); for(Field f : Reflection.getFields(clazz)){ fieldList.add(new ReflectField(this,f)); } this.fields = fieldList.toArray(new ReflectField[fieldList.size()]); this.declaredFields = getDeclaredMembers(fieldList).toArray(new ReflectField[]{}); }
/** * Attempt to find a {@link Field field} on the supplied {@link Class} with the supplied <code>name</code>. * * Searches all superclasses up to {@link Object}. * * @param clazz the class to introspect * @param name the name of the field * @return the corresponding Field object, or <code>null</code> if not found */ public static Field findField(Class<?> clazz, String name) { return findField(clazz, name, null); }
@Override public String convertToString(Method m) throws Throwable { return Reflection.fullQualifyName(m); } }
@Override public Object getValue(ElEvalContext context, Object instance) throws Throwable { return field.getValue(null); }
public AElement tryGetElement(String name) { initElements(); for(AElement e : elements){ if(e.getName().equals(name)){ return e; } } return null; }
@Override public Object invoke(ElEvalContext context, Object[] args) throws Throwable { return m.invokeStatic(args); } }
protected ReflectConstructor(ReflectClass reflectiveClass, Constructor<?> javaConstructor){ super(reflectiveClass,javaConstructor); this.reflectedConstructor = javaConstructor; this.initialize(); }
@Override public Annotation[] getAnnotations() { return p.getAnnotations(); }
@SuppressWarnings("unchecked") public <T> T newInstance(){ return (T)reflectClass.newInstance(); }