@Override public void handle( final AnnotationValues<ListenerSupport> annotation, final JCAnnotation source, final JavacNode annotationNode) { deleteAnnotationIfNeccessary(annotationNode, ListenerSupport.class); JavacType type = JavacType.typeOf(annotationNode, source); if (type.isAnnotation() || type.isInterface()) { annotationNode.addError(canBeUsedOnClassAndEnumOnly(ListenerSupport.class)); return; } List<Object> listenerInterfaces = annotation.getActualExpressions("value"); if (listenerInterfaces.isEmpty()) { annotationNode.addError( String.format( "@%s has no effect since no interface types were specified.", ListenerSupport.class.getName())); return; } List<TypeSymbol> resolvedInterfaces = resolveInterfaces(annotationNode, ListenerSupport.class, listenerInterfaces); for (TypeSymbol interfaze : resolvedInterfaces) { handler.addListenerField(type, interfaze); handler.addAddListenerMethod(type, interfaze); handler.addRemoveListenerMethod(type, interfaze); addFireListenerMethods(type, interfaze); } type.editor().rebuild(); }
private void addAllFireListenerMethods( final JavacType type, final TypeSymbol interfaze, final TypeSymbol superInterfaze) { for (Symbol member : superInterfaze.getEnclosedElements()) { if (member.getKind() != ElementKind.METHOD) continue; handler.addFireListenerMethod(type, interfaze, (MethodSymbol) member); } ClassType superInterfazeType = (ClassType) superInterfaze.type; if (superInterfazeType.interfaces_field != null) for (Type iface : superInterfazeType.interfaces_field) { addAllFireListenerMethods(type, interfaze, iface.asElement()); } }