Package javax.lang.model.type

Examples of javax.lang.model.type.TypeMirror


    for ( Element elem : element.getEnclosedElements() ) {
      if ( !expectedElementKind.equals( elem.getKind() ) ) {
        continue;
      }

      TypeMirror mirror;
      String name = elem.getSimpleName().toString();
      if ( ElementKind.METHOD.equals( elem.getKind() ) ) {
        name = StringUtil.getPropertyName( name );
        mirror = ( ( ExecutableElement ) elem ).getReturnType();
      }
      else {
        mirror = elem.asType();
      }

      if ( name == null || !name.equals( propertyName ) ) {
        continue;
      }

      if ( explicitTargetEntity != null ) {
        // TODO should there be a check of the target entity class and if it is loadable?
        return explicitTargetEntity;
      }

      switch ( mirror.getKind() ) {
        case INT: {
          return "java.lang.Integer";
        }
        case LONG: {
          return "java.lang.Long";
        }
        case BOOLEAN: {
          return "java.lang.Boolean";
        }
        case BYTE: {
          return "java.lang.Byte";
        }
        case SHORT: {
          return "java.lang.Short";
        }
        case CHAR: {
          return "java.lang.Char";
        }
        case FLOAT: {
          return "java.lang.Float";
        }
        case DOUBLE: {
          return "java.lang.Double";
        }
        case DECLARED: {
          return mirror.toString();
        }
        case TYPEVAR: {
          return mirror.toString();
        }
      }
    }

    context.logMessage(
View Full Code Here


    for ( MetaEntity entity : entities ) {
      if ( entity.equals( containedEntity ) ) {
        continue;
      }
      for ( Element subElement : ElementFilter.fieldsIn( entity.getTypeElement().getEnclosedElements() ) ) {
        TypeMirror mirror = subElement.asType();
        if ( !TypeKind.DECLARED.equals( mirror.getKind() ) ) {
          continue;
        }
        boolean contains = mirror.accept( visitor, subElement );
        if ( contains ) {
          return true;
        }
      }
      for ( Element subElement : ElementFilter.methodsIn( entity.getTypeElement().getEnclosedElements() ) ) {
        TypeMirror mirror = subElement.asType();
        if ( !TypeKind.DECLARED.equals( mirror.getKind() ) ) {
          continue;
        }
        boolean contains = mirror.accept( visitor, subElement );
        if ( contains ) {
          return true;
        }
      }
    }
View Full Code Here

      TypeElement returnedElement = (TypeElement) context.getTypeUtils().asElement( declaredType );

      String fqNameOfReturnType = returnedElement.getQualifiedName().toString();
      String collection = Constants.COLLECTIONS.get( fqNameOfReturnType );
      if ( collection != null ) {
        TypeMirror collectionElementType = TypeUtils.getCollectionElementType(
            declaredType, fqNameOfReturnType, null, context
        );
        returnedElement = (TypeElement) context.getTypeUtils().asElement( collectionElementType );
      }
View Full Code Here

      String string = element.getSimpleName().toString();
      if ( !StringUtil.isPropertyName( string ) ) {
        return Boolean.FALSE;
      }

      TypeMirror returnType = t.getReturnType();
      return returnType.accept( this, element );
    }
View Full Code Here

    }
    return type.toString();
  }

  public static TypeElement getSuperclassTypeElement(TypeElement element) {
    final TypeMirror superClass = element.getSuperclass();
    //superclass of Object is of NoType which returns some other kind
    if ( superClass.getKind() == TypeKind.DECLARED ) {
      //F..king Ch...t Have those people used their horrible APIs even once?
      final Element superClassElement = ( (DeclaredType) superClass ).asElement();
      return (TypeElement) superClassElement;
    }
    else {
View Full Code Here

    }
  }

  public static String extractClosestRealTypeAsString(TypeMirror type, Context context) {
    if ( type instanceof TypeVariable ) {
      final TypeMirror compositeUpperBound = ( (TypeVariable) type ).getUpperBound();
      return extractClosestRealTypeAsString( compositeUpperBound, context );
    }
    else {
      return context.getTypeUtils().erasure( type ).toString();
    }
View Full Code Here

    accessTypeInfo = new AccessTypeInformation( fqcn, null, defaultAccessType );
    context.addAccessTypeInformation( fqcn, accessTypeInfo );
  }

  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();
    }
View Full Code Here

  }

  private static void printClassDeclaration(MetaEntity entity, PrintWriter pw, Context context) {
    pw.print( "public abstract class " + entity.getSimpleName() + META_MODEL_CLASS_NAME_SUFFIX );

    final TypeMirror superClass = entity.getTypeElement().getSuperclass();
    //superclass of Object is of NoType which returns some other kind
    if ( superClass.getKind() == TypeKind.DECLARED ) {
      //F..king Ch...t Have those people used their horrible APIs even once?
      final Element superClassElement = ( (DeclaredType) superClass ).asElement();
      String superClassName = ( (TypeElement) superClassElement ).getQualifiedName().toString();
      if ( extendsSuperMetaModel( superClassElement, entity.isMetaComplete(), context ) ) {
        pw.print( " extends " + superClassName + META_MODEL_CLASS_NAME_SUFFIX );
View Full Code Here

      String string = p.getSimpleName().toString();
      if ( !StringUtil.isPropertyName( string ) ) {
        return null;
      }

      TypeMirror returnType = t.getReturnType();
      return returnType.accept( this, p );
    }
View Full Code Here

    return new AnnotationMetaSingleAttribute( entity, element, TypeUtils.toTypeString( t ) );
  }

  public AnnotationMetaAttribute visitTypeVariable(TypeVariable t, Element element) {
    // METAGEN-29 - for a type variable we use the upper bound
    TypeMirror mirror = t.getUpperBound();
    TypeMirror erasedType = context.getTypeUtils().erasure( mirror );
    return new AnnotationMetaSingleAttribute(
        entity, element, erasedType.toString()
    );
  }
View Full Code Here

TOP

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

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.