List of usage examples for javax.lang.model.element TypeElement getInterfaces
List<? extends TypeMirror> getInterfaces();
From source file:auto.parse.processor.AutoParseProcessor.java
private void findLocalAndInheritedMethods(TypeElement type, List<ExecutableElement> methods) { note("Looking at methods in " + type); Types typeUtils = processingEnv.getTypeUtils(); Elements elementUtils = processingEnv.getElementUtils(); for (TypeMirror superInterface : type.getInterfaces()) { findLocalAndInheritedMethods((TypeElement) typeUtils.asElement(superInterface), methods); }// w w w . j a v a2 s. c o m if (type.getSuperclass().getKind() != TypeKind.NONE) { // Visit the superclass after superinterfaces so we will always see the implementation of a // method after any interfaces that declared it. findLocalAndInheritedMethods((TypeElement) typeUtils.asElement(type.getSuperclass()), methods); } // Add each method of this class, and in so doing remove any inherited method it overrides. // This algorithm is quadratic in the number of methods but it's hard to see how to improve // that while still using Elements.overrides. List<ExecutableElement> theseMethods = ElementFilter.methodsIn(type.getEnclosedElements()); eclipseHack().sortMethodsIfSimulatingEclipse(theseMethods); for (ExecutableElement method : theseMethods) { if (!method.getModifiers().contains(Modifier.PRIVATE)) { boolean alreadySeen = false; for (Iterator<ExecutableElement> methodIter = methods.iterator(); methodIter.hasNext();) { ExecutableElement otherMethod = methodIter.next(); if (elementUtils.overrides(method, otherMethod, type)) { methodIter.remove(); } else if (method.getSimpleName().equals(otherMethod.getSimpleName()) && method.getParameters().equals(otherMethod.getParameters())) { // If we inherit this method on more than one path, we don't want to add it twice. alreadySeen = true; } } if (!alreadySeen) { methods.add(method); } } } }
From source file:com.googlecode.androidannotations.helper.ValidatorHelper.java
public void doesNotExtendOtherInterfaces(TypeElement element, IsValid valid) { if (element.getInterfaces().size() > 0) { valid.invalidate();/*from www. j a v a 2 s . c om*/ annotationHelper.printAnnotationError(element, "%s can only be used on an interface that does not extend other interfaces"); } }
From source file:org.androidannotations.helper.ValidatorHelper.java
public void doesNotExtendInvalidInterfaces(TypeElement element, IsValid valid) { if (element.getInterfaces().size() > 0) { boolean isValid = true; for (TypeMirror iface : element.getInterfaces()) { if (!VALID_REST_INTERFACES.contains(iface.toString())) { isValid = false;/*from w ww. ja v a 2s .c om*/ break; } } if (!isValid) { valid.invalidate(); annotationHelper.printAnnotationError(element, "%s interfaces can only extend the following interfaces: " + VALID_REST_INTERFACES); } } }