Package javax.lang.model.type

Examples of javax.lang.model.type.DeclaredType


  private String[] getCollectionType(String propertyName, String explicitTargetEntity) {
    String types[] = new String[2];
    for ( Element elem : element.getEnclosedElements() ) {
      if ( elem.getSimpleName().toString().equals( propertyName ) ) {
        DeclaredType type = ( ( DeclaredType ) elem.asType() );
        if ( explicitTargetEntity == null ) {
          types[0] = TypeUtils.extractClosestRealTypeAsString( type.getTypeArguments().get( 0 ), context );
        }
        else {
          types[0] = explicitTargetEntity;
        }
        types[1] = COLLECTIONS.get( type.asElement().toString() );
      }
    }
    return types;
  }
View Full Code Here


    methods = scanMethods(declaration);
    validate();
  }
 
  private void validate() {
    DeclaredType factory = ProcessorUtil.findFactory(declaration);
    if (factory == null) {
      success = false;
      messager.printMessage(ERROR, "Interface must extend com.artemis.EntityFactory", declaration);
      return;
    }
   
    // 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(),
View Full Code Here

 
  public static boolean isString(TypeMirror mirror) {
    if (!(mirror instanceof DeclaredType))
      return false;
   
    DeclaredType type = (DeclaredType) mirror;
    Element e = type.asElement();
    if (!(e instanceof TypeElement))
      return false;
   
    TypeElement typeElement = (TypeElement) e;
   
View Full Code Here

      if ( !elem.getSimpleName().toString().equals( propertyName ) ) {
        continue;
      }

      DeclaredType type = ( ( DeclaredType ) elem.asType() );
      determineTargetType( type, propertyName, explicitTargetEntity, types );
      determineCollectionType( type, types );
      if ( types[1].equals( "javax.persistence.metamodel.MapAttribute" ) ) {
        determineMapType( type, explicitMapKeyClass, types );
      }
View Full Code Here

      if ( !propertyName.equals( elementPropertyName ) ) {
        continue;
      }

      DeclaredType type = determineDeclaredType( elem );
      if ( type == null ) {
        continue;
      }

      return determineTypes( propertyName, explicitTargetEntity, explicitMapKeyClass, type );
View Full Code Here

    }
    return null;
  }

  private DeclaredType determineDeclaredType(Element elem) {
    DeclaredType type = null;
    if ( elem.asType() instanceof DeclaredType ) {
      type = ( (DeclaredType) elem.asType() );
    }
    else if ( elem.asType() instanceof ExecutableType ) {
      ExecutableType executableType = (ExecutableType) elem.asType();
View Full Code Here

    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 {
View Full Code Here

  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() + "]");
View Full Code Here

    "type != null",
    "type.getKind() == javax.lang.model.type.TypeKind.DECLARED"
  })
  @Ensures("result == null || result.getDeclaredName().equals(type.toString())")
  ClassName getClassNameForType(TypeMirror type) {
    DeclaredType tmp = (DeclaredType) type;
    TypeElement element = (TypeElement) tmp.asElement();
    String binaryName = elementUtils.getBinaryName(element)
        .toString().replace('.', '/');
    return new ClassName(binaryName, type.toString());
  }
View Full Code Here

    }

    public TypeElement asDecl(TypeMirror m) {
        m = env.getTypeUtils().erasure(m);
        if (m.getKind().equals(TypeKind.DECLARED)) {
            DeclaredType d = (DeclaredType) m;
            return (TypeElement) d.asElement();
        } else
            return null;
    }
View Full Code Here

TOP

Related Classes of javax.lang.model.type.DeclaredType

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.