public static Method getReadMethodObject(FeatureDescriptor _featureDescriptor) { if (_featureDescriptor instanceof MethodDescriptor) { MethodDescriptor md = (MethodDescriptor) _featureDescriptor; return md.getMethod(); } if (_featureDescriptor instanceof EventSetDescriptor) { EventSetDescriptor md = (EventSetDescriptor) _featureDescriptor; Method em = md.getGetListenerMethod();// md.getGetListenerMethod(); if (em != null) return em; return null;// md.getGetListenerMethod(); } if (_featureDescriptor instanceof PropertyDescriptor) { PropertyDescriptor md = (PropertyDescriptor) _featureDescriptor; Method m = md.getReadMethod(); if (m != null) return m; Method m2 = md.getWriteMethod(); if (m2 != null) return m2; } return null; }
if (descriptor.getGetListenerMethod() != null) builder.append(",").append("getMethod=").append(descriptor.getGetListenerMethod().getName());
public static EventListener[] getListeners(Object bean, EventSetDescriptor eventSetDescriptor) { Method method = eventSetDescriptor.getGetListenerMethod(); try { return (EventListener[]) method.invoke(bean); } catch (IllegalAccessException exception) { throw new BeanException("Cannot get event set listeners: " + eventSetDescriptor.getName(), exception); } catch (InvocationTargetException exception) { throw new BeanException("Cannot get event set listeners: " + eventSetDescriptor.getName(), exception); } }
public static boolean equals(EventSetDescriptor descriptor1, EventSetDescriptor descriptor2) { if (descriptor1 == descriptor2) { return true; } // TODO: check all properties return nullEquals(descriptor1.getAddListenerMethod(), descriptor2.getAddListenerMethod()) && nullEquals(descriptor1.getRemoveListenerMethod(), descriptor2.getRemoveListenerMethod()) && nullEquals(descriptor1.getGetListenerMethod(), descriptor2.getGetListenerMethod()) && Arrays.equals(descriptor1.getListenerMethods(), descriptor2.getListenerMethods()) && descriptor1.isUnicast() == descriptor2.isUnicast(); }
public static EventSetDescriptor getDescriptor(BeanInfo beanInfo, String eventSetName, String listenerMethodName) { checkNotNull(beanInfo, "beanInfo"); checkNotNull(eventSetName, "eventSetName"); checkNotNull(listenerMethodName, "listenerMethodName"); EventSetDescriptor descriptor = getDescriptor(beanInfo, eventSetName); MethodDescriptor listenerMethodDescriptor = BeanUtils.getListenerMethodDescriptor(descriptor, listenerMethodName); Method[] listenerMethods = new Method[] {listenerMethodDescriptor.getMethod()}; try { return new EventSetDescriptor(descriptor.getName(), descriptor.getListenerType(), listenerMethods, descriptor.getAddListenerMethod(), descriptor.getRemoveListenerMethod(), descriptor.getGetListenerMethod()); } catch (IntrospectionException exception) { throw new BeanException("Cannot construct event set descriptor", exception); } }
eventSet.getAddListenerMethod(), eventSet.getRemoveListenerMethod(), eventSet.getGetListenerMethod());