public Method getSetter() { return null != setter ? setter.getReflectedMethod() : null; }
public Method getGetter() { return null != getter ? getter.getReflectedMethod() : null; }
public ReflectMethod getMethod(final Method m){ for(ReflectMethod rm : methods){ if(rm.getReflectedMethod().equals(m)){ return rm; } } return null; }
protected Doc searchUp(ReflectMethod m) { Class<?> c = m.getReflectedMethod().getDeclaringClass(); for(Class<?> ic : c.getInterfaces()) { try { Method im = ic.getMethod(m.getName(), m.getReflectedMethod().getParameterTypes()); return im.getAnnotation(Doc.class); } catch (NoSuchMethodException e) { //do nothing. } } return null; }
public ElInstanceMethod(ReflectMethod m,Object instance) { this.m = m; this.size = m.getReflectedMethod().isVarArgs() ? VAR_ARGS : m.getParameters().length; this.instance = instance; }
public ReflectMethod getMethod(String name,Class<?> returnType,Class<?>... argumentTypes){ ReflectMethod m = getMethod(name, argumentTypes); return null == m ? null : (m.getReflectedMethod().getReturnType().equals(returnType) ? m : null); }
protected Doc searchUp(ReflectMethod m, ReflectParameter p) { Class<?> c = m.getReflectedMethod().getDeclaringClass(); for(Class<?> ic : c.getInterfaces()) { try { Method im = ic.getMethod(m.getName(), m.getReflectedMethod().getParameterTypes()); return im.getParameters()[p.getIndex()-1].getAnnotation(Doc.class); } catch (NoSuchMethodException e) { //do nothing. } } return null; }
private ReflectMethod findGetter(Class<?> fieldType,String nameToFind){ for(ReflectMethod rm : reflectClass.getMethods()){ Method m = rm.getReflectedMethod(); if(m.getParameterTypes().length == 0 && Primitives.wrap(m.getReturnType()).isAssignableFrom(fieldType)){ if(m.getName().equals(nameToFind)){ return rm; } } } return null; }
private ReflectMethod findSetter(Class<?> fieldType,String nameToFind){ //iterate all public methods. for(ReflectMethod rm : reflectClass.getMethods()){ Method m = rm.getReflectedMethod(); if(m.getParameterTypes().length == 1 && fieldType.isAssignableFrom(Primitives.wrap(m.getParameterTypes()[0]))){ if(m.getName().equals(nameToFind)){ return rm; } } } return null; }
public ReflectMethod getMethod(final String name,final Class<?>... argumentTypes){ for(ReflectMethod rm : methods){ if(rm.getName().equals(name)){ Method m = rm.getReflectedMethod();
public ElInstanceMethods add(ReflectMethod m) { if(!m.getName().equals(name)){ throw new IllegalArgumentException("Method name '" + m.getName() + "' must be '" + name + "'"); } if(m.getReflectedMethod().isVarArgs()){ defaultMethod = m; }else{ Integer i = m.getParameters().length; if(!methods().containsKey(i)){ methods().put(i, m); } } return this; }
protected ReflectField(ReflectClass reflectiveClass, Field field){ super(reflectiveClass,field); this.field = field; this.type = field.getType(); this.setter = findSetter(); this.getter = findGetter(); this.accessor = reflectiveClass.getAccessor(); if(null != setter){ setter.setSetterOf(this); } if(null != getter){ getter.setGetterOf(this); } this.fieldAccessorIndex = null == accessor ? -1 : accessor.getFieldIndex(field); this.setterAccessorIndex = null == setter || null == accessor ? -1 : accessor.getMethodIndex(setter.getReflectedMethod()); this.getterAccessorIndex = null == getter || null == accessor ? -1 : accessor.getMethodIndex(getter.getReflectedMethod()); this.initialize(); }
if(m.isPublic() && m.isStatic()) { if(annotatedOnly && !isElFriendly(m.getReflectedMethod())){ continue;
public ReflectDeleteEntityListener(Object inst, ReflectMethod m) { this.inst = inst; this.method = m; if(m.getParameters().length == 1) { this.transactional = false; ReflectParameter p = m.getParameters()[0]; if(p.getType().equals(Object.class)) { func = (e) -> m.invoke(inst, e.getId()); return; }else if(p.getType().equals(DeleteEntityEvent.class)) { func = (e) -> m.invoke(inst, e); return; } } else if(m.getParameters().length == 2) { this.transactional = true; ReflectParameter p0 = m.getParameters()[0]; ReflectParameter p1 = m.getParameters()[1]; if(p0.getType().equals(Object.class) && p1.getType().equals(TransactionStatus.class)) { func = (e) -> m.invoke(inst, e.getId(), e.getTransactionStatus()); return; } if(p0.getType().equals(DeleteEntityEvent.class) && p1.getType().equals(TransactionStatus.class)) { func = (e) -> m.invoke(inst, e, e.getTransactionStatus()); return; } } throw new IllegalArgumentException("Incorrect parameters in method '" + Reflection.fullQualifyName(m.getReflectedMethod()) + "' for 'DeleteEntity' event"); }
Reflection.fullQualifyName(m.getReflectedMethod()) + "' for '" + eventType.getSimpleName() + "' event");
Method m = rm.getReflectedMethod();
operations.put(new MSignature(name, rm.getReflectedMethod()), new MOperation(oi, rm));