Examples of TypeElement


Examples of javax.lang.model.element.TypeElement

  public static TypeMirror getCollectionElementType(DeclaredType t, String fqNameOfReturnedType, String explicitTargetEntityName, Context context) {
    TypeMirror collectionElementType;
    if ( explicitTargetEntityName != null ) {
      Elements elements = context.getElementUtils();
      TypeElement element = elements.getTypeElement( explicitTargetEntityName );
      collectionElementType = element.asType();
    }
    else {
      List<? extends TypeMirror> typeArguments = t.getTypeArguments();
      if ( typeArguments.size() == 0 ) {
        throw new MetaModelGenerationException( "Unable to determine collection type" );
View Full Code Here

Examples of javax.lang.model.element.TypeElement

      this.context = context;
    }

    @Override
    public String visitDeclared(DeclaredType declaredType, Element element) {
      TypeElement returnedElement = (TypeElement) context.getTypeUtils().asElement( declaredType );
      String fqNameOfReturnType = null;
      if ( containsAnnotation( returnedElement, Embeddable.class ) ) {
        fqNameOfReturnType = returnedElement.getQualifiedName().toString();
      }
      return fqNameOfReturnType;
    }
View Full Code Here

Examples of javax.lang.model.element.TypeElement

  }

  @Override
  public AnnotationMetaAttribute visitDeclared(DeclaredType declaredType, Element element) {
    AnnotationMetaAttribute metaAttribute = null;
    TypeElement returnedElement = (TypeElement) context.getTypeUtils().asElement( declaredType );
    // WARNING: .toString() is necessary here since Name equals does not compare to String
    String fqNameOfReturnType = returnedElement.getQualifiedName().toString();
    String collection = Constants.COLLECTIONS.get( fqNameOfReturnType );
    String targetEntity = getTargetEntity( element.getAnnotationMirrors() );
    if ( collection != null ) {
      return createMetaCollectionAttribute(
          declaredType, element, fqNameOfReturnType, collection, targetEntity
      );
    }
    else if ( isBasicAttribute( element, returnedElement ) ) {
      String type = targetEntity != null ? targetEntity : returnedElement.getQualifiedName().toString();
      return new AnnotationMetaSingleAttribute( entity, element, type );
    }
    return metaAttribute;
  }
View Full Code Here

Examples of javax.lang.model.element.TypeElement

    if ( TypeUtils.containsAnnotation( element, ElementCollection.class ) ) {
      String explicitTargetEntity = getTargetEntity( element.getAnnotationMirrors() );
      TypeMirror collectionElementType = TypeUtils.getCollectionElementType(
          declaredType, fqNameOfReturnType, explicitTargetEntity, context
      );
      final TypeElement collectionElement = (TypeElement) context.getTypeUtils()
          .asElement( collectionElementType );
      AccessTypeInformation accessTypeInfo = context.getAccessTypeInfo( collectionElement.getQualifiedName().toString() );
      if ( accessTypeInfo == null ) {
        AccessType explicitAccessType = TypeUtils.determineAnnotationSpecifiedAccessType(
            collectionElement
        );
        accessTypeInfo = new AccessTypeInformation(
            collectionElement.getQualifiedName().toString(),
            explicitAccessType,
            entity.getEntityAccessTypeInfo().getAccessType()
        );
        context.addAccessTypeInformation(
            collectionElement.getQualifiedName().toString(), accessTypeInfo
        );
      }
      else {
        accessTypeInfo.setDefaultAccessType( entity.getEntityAccessTypeInfo().getAccessType() );
      }
View Full Code Here

Examples of javax.lang.model.element.TypeElement

  }

  @Override
  public Boolean visitArray(ArrayType t, Element element) {
    TypeMirror componentMirror = t.getComponentType();
    TypeElement componentElement = (TypeElement) context.getTypeUtils().asElement( componentMirror );

    return Constants.BASIC_ARRAY_TYPES.contains( componentElement.getQualifiedName().toString() );
  }
View Full Code Here

Examples of javax.lang.model.element.TypeElement

    if ( ElementKind.ENUM.equals( element.getKind() ) ) {
      return Boolean.TRUE;
    }

    if ( ElementKind.CLASS.equals( element.getKind() ) || ElementKind.INTERFACE.equals( element.getKind() ) ) {
      TypeElement typeElement = ( (TypeElement) element );
      String typeName = typeElement.getQualifiedName().toString();
      if ( Constants.BASIC_TYPES.contains( typeName ) ) {
        return Boolean.TRUE;
      }
      if ( TypeUtils.containsAnnotation( element, Embeddable.class ) ) {
        return Boolean.TRUE;
      }
      for ( TypeMirror mirror : typeElement.getInterfaces() ) {
        TypeElement interfaceElement = (TypeElement) context.getTypeUtils().asElement( mirror );
        if ( "java.io.Serializable".equals( interfaceElement.getQualifiedName().toString() ) ) {
          return Boolean.TRUE;
        }
      }
    }
    return Boolean.FALSE;
View Full Code Here

Examples of javax.lang.model.element.TypeElement

    log(annotations.toString());
    log(elements.toString());

    for (Element e : elements) {
      TypeElement providerImplementer = (TypeElement) e;
      AnnotationMirror providerAnnotation = getAnnotationMirror(e, ServiceProvider.class);
      DeclaredType providerInterface = getProviderInterface(providerAnnotation);
      TypeElement providerType = (TypeElement) providerInterface.asElement();

      log("provider interface: " + providerType.getQualifiedName());
      log("provider implementer: " + providerImplementer.getQualifiedName());

      try {
        verifyImplementer(providerImplementer, providerType);
      } catch (VerifyException ex) {
View Full Code Here

Examples of javax.lang.model.element.TypeElement

        return className;
      }
      return pkg.getQualifiedName() + "." + className;
    }

    TypeElement typeElement = (TypeElement) enclosingElement;
    return getBinaryNameImpl(typeElement, typeElement.getSimpleName() + "$" + className);
  }
View Full Code Here

Examples of javax.lang.model.element.TypeElement

  private AnnotationMirror getAnnotationMirror(Element e, Class<? extends Annotation> klass) {
    List<? extends AnnotationMirror> annotationMirrors = e.getAnnotationMirrors();
    for (AnnotationMirror mirror : annotationMirrors) {
      log("mirror: " + mirror);
      DeclaredType type = mirror.getAnnotationType();
      TypeElement typeElement = (TypeElement) type.asElement();
      if (typeElement.getQualifiedName().contentEquals(klass.getName())) {
        return mirror;
      } else {
        log("klass name: [" + klass.getName() + "]");
        log("type name: [" + typeElement.getQualifiedName() + "]");
      }
    }
    return null;
  }
View Full Code Here

Examples of javax.lang.model.element.TypeElement

        new Predicate<AnnotationMirror>() {
          @Override
          public boolean apply(AnnotationMirror mirror) {
            log("mirror: " + mirror);
            DeclaredType type = mirror.getAnnotationType();
            TypeElement typeElement = (TypeElement) type.asElement();
            return typeElement.getQualifiedName().contentEquals(
                annotationElement.getQualifiedName());
          }
        });
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.