Package javax.lang.model.element

Examples of javax.lang.model.element.TypeElement


                    }
                    name = prefix + name;
                    // if the field type is a nested parameter then iterate through its fields
                    TypeMirror fieldType = fieldElement.asType();
                    String fieldTypeName = fieldType.toString();
                    TypeElement fieldTypeElement = findTypeElement(roundEnv, fieldTypeName);
                    UriParams fieldParams = null;
                    if (fieldTypeElement != null) {
                        fieldParams = fieldTypeElement.getAnnotation(UriParams.class);
                    }
                    if (fieldParams != null) {
                        String nestedPrefix = prefix;
                        String extraPrefix = fieldParams.prefix();
                        if (!Strings.isNullOrEmpty(extraPrefix)) {
                            nestedPrefix += extraPrefix;
                        }
                        findClassProperties(roundEnv, sortedMap, fieldTypeElement, nestedPrefix);
                    } else {
                        String docComment = elementUtils.getDocComment(fieldElement);
                        if (Strings.isNullOrEmpty(docComment)) {
                            String setter = "set" + fieldName.substring(0, 1).toUpperCase();
                            if (fieldName.length() > 1) {
                                setter += fieldName.substring(1);
                            }
                            //  lets find the setter
                            List<ExecutableElement> methods = ElementFilter.methodsIn(classElement.getEnclosedElements());
                            for (ExecutableElement method : methods) {
                                String methodName = method.getSimpleName().toString();
                                if (setter.equals(methodName) && method.getParameters().size() == 1) {
                                    String doc = elementUtils.getDocComment(method);
                                    if (!Strings.isNullOrEmpty(doc)) {
                                        docComment = doc;
                                        break;
                                    }
                                }
                            }
                        }
                        if (docComment == null) {
                            docComment = "";
                        }
                        List<String> values = new ArrayList<String>();
                        values.add("    <td>" + fieldTypeName + "</td>");
                        values.add("    <td>" + docComment.trim() + "</td>");

                        // TODO would be nice here to create a default endpoint/consumer object
                        // and return the default value of the field so we can put it into the docs
                        Object defaultValue = null;
                        if (defaultValue != null) {
                            values.add("    <td>" + defaultValue + "</td>");
                        }
                        if (sortedMap.containsKey(name)) {
                            error("Duplicate parameter annotation named '" + name + "' on class " + classElement.getQualifiedName());
                        } else {
                            sortedMap.put(name, values);
                        }
                    }
                }
            }
            TypeElement baseTypeElement = null;
            TypeMirror superclass = classElement.getSuperclass();
            if (superclass != null) {
                String superClassName = canonicalClassName(superclass.toString());
                baseTypeElement = findTypeElement(roundEnv, superClassName);
            }
View Full Code Here


    protected TypeElement findTypeElement(RoundEnvironment roundEnv, String className) {
        if (!Strings.isNullOrEmpty(className) && !"java.lang.Object".equals(className)) {
            Set<? extends Element> rootElements = roundEnv.getRootElements();
            for (Element rootElement : rootElements) {
                if (rootElement instanceof TypeElement) {
                    TypeElement typeElement = (TypeElement) rootElement;
                    String aRootName = canonicalClassName(typeElement.getQualifiedName().toString());
                    if (className.equals(aRootName)) {
                        return typeElement;
                    }
                }
            }
View Full Code Here

      //we don't know if an entity go up
      //
      //superclasses are always treated after their entities
      //and their access type are discovered
      //FIXME is it really true if only the superclass is changed
      TypeElement superClass = element;
      do {
        superClass = TypeUtils.getSuperclassTypeElement( superClass );
        if ( superClass != null ) {
          if ( TypeUtils.containsAnnotation( superClass, Entity.class, MappedSuperclass.class ) ) {
            //FIXME make it work for XML
View Full Code Here

    @Override
    public AnnotationMetaAttribute visitDeclared(DeclaredType declaredType, Element element) {
      //FIXME consider XML
      if ( isPersistent( element ) ) {
        TypeElement returnedElement = ( TypeElement ) context.getProcessingEnvironment()
            .getTypeUtils()
            .asElement( declaredType );
        // WARNING: .toString() is necessary here since Name equals does not compare to String
        String fqElementName = returnedElement.getQualifiedName().toString();
        String collection = COLLECTIONS.get( fqElementName );
        String targetEntity = getTargetEntity( element.getAnnotationMirrors() );
        if ( collection != null ) {
          if ( TypeUtils.containsAnnotation( element, ElementCollection.class ) ) {
            TypeMirror collectionElementType = getCollectionElementType( declaredType, fqElementName );
            final TypeElement collectionElement = ( TypeElement ) context.getProcessingEnvironment()
                .getTypeUtils()
                .asElement( collectionElementType );
            this.parent.context.processElement(
                collectionElement,
                this.parent.defaultAccessTypeForElement
View Full Code Here

      String baseName = extensionTag.baseClassName();
      description.append("<p><b>Extended tag: </b>");
      description.append(baseName);
      description.append("</p>");

      TypeElement declaration = getInterfaceDeclaration(baseName + "Declaration");
      if (declaration != null) {
        UIComponentTag baseComponentTag = declaration.getAnnotation(UIComponentTag.class);
        if (baseComponentTag != null) {
          description.append(createDescription(baseComponentTag));
        }
      }
    }
View Full Code Here

    }
   
    // if empty, we're probably extending an existing factory
    if (factory.getTypeArguments().size() > 0) {
      DeclaredType argument = ((DeclaredType) factory.getTypeArguments().get(0));
      TypeElement factoryType = (TypeElement) argument.asElement();
      if (!factoryType.getQualifiedName().equals(declaration.getQualifiedName())) {
        success = false;
        messager.printMessage(ERROR,
            format("Expected EntityFactory<%s>, but found EntityFactory<%s>",
                declaration.getSimpleName(),
                factoryType.getSimpleName()),
            declaration);
      }
    }
   
    for (FactoryMethod method : methods)
View Full Code Here

      return null;
    }
  }

  private FactoryMethod bindMethod(ExecutableElement method, DeclaredType value) {
    TypeElement component = (TypeElement)value.asElement();
    components.add(component);
   
    // scan for UseSetter
    String setterMethod = null;
    AnnotationMirror setterMirror = ProcessorUtil.mirror(UseSetter.class, method);
View Full Code Here

  }

  private Map<String, TypeElement> readGlobalCRefs(TypeElement declaration) {
    Map<String, TypeElement> autoResolvable = new HashMap<String, TypeElement>();
    for (AnnotationValue value : readCRef(declaration)) {
      TypeElement type = (TypeElement)((DeclaredType)value.getValue()).asElement();
      this.components.add(type);
      autoResolvable.put(key(type), type);
    }
   
    return autoResolvable;
View Full Code Here

 
  private static void parentInterfaces(List<? extends TypeMirror> interfaceMirrors,
      Set<TypeElement> target) {
   
    for (TypeMirror mirror : interfaceMirrors) {
      TypeElement found = (TypeElement) ((DeclaredType) mirror).asElement();
      target.add(found);
      parentInterfaces(found.getInterfaces(), target);
    }
  }
View Full Code Here

    DeclaredType type = (DeclaredType) mirror;
    Element e = type.asElement();
    if (!(e instanceof TypeElement))
      return false;
   
    TypeElement typeElement = (TypeElement) e;
   
    return typeElement.getQualifiedName().toString().equals("java.lang.String");
  }
View Full Code Here

TOP

Related Classes of javax.lang.model.element.TypeElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.