Examples of TypeMirror


Examples of javax.lang.model.type.TypeMirror

    return typeMirror.accept(
        new SimpleTypeVisitor6<TypeMirror, Void>() {

          @Override
          public TypeMirror visitDeclared(DeclaredType declaredType, Void aVoid) {
            TypeMirror eraseType = typeUtils.erasure( declaredType );
            if ( typeUtils.isSameType( eraseType, defaultGroupSequenceProviderType ) ) {
              List<? extends TypeMirror> typeArguments = declaredType.getTypeArguments();
              if ( !typeArguments.isEmpty() ) {
                return typeArguments.get( 0 );
              }
              return null;
            }

            List<? extends TypeMirror> superTypes = typeUtils.directSupertypes( declaredType );
            for ( TypeMirror superType : superTypes ) {
              TypeMirror genericProviderType = superType.accept( this, aVoid );
              if ( genericProviderType != null ) {
                return genericProviderType;
              }
            }
            return null;
View Full Code Here

Examples of javax.lang.model.type.TypeMirror

        constraintMetaAnnotation
    );

    for ( AnnotationValue oneValidatorClassReference : validatorClassReferences ) {

      TypeMirror supportedType = getSupportedType( oneValidatorClassReference );

      if ( typeUtils.isAssignable( type, supportedType ) ) {
        theValue.add( supportedType );
      }
    }
View Full Code Here

Examples of javax.lang.model.type.TypeMirror

    return annotationApiHelper.keepLowestTypePerHierarchy( theValue );
  }

  private TypeMirror getSupportedType(AnnotationValue oneValidatorClassReference) {

    TypeMirror validatorType = oneValidatorClassReference.accept(
        new SimpleAnnotationValueVisitor6<TypeMirror, Void>() {

          @Override
          public TypeMirror visitType(TypeMirror t, Void p) {
            return t;
          }
        }, null
    );

    // contains the bindings of the type parameters from the implemented
    // ConstraintValidator interface, e.g. "ConstraintValidator<CheckCase, String>"
    TypeMirror constraintValidatorImplementation = getConstraintValidatorSuperType( validatorType );

    return constraintValidatorImplementation.accept(
        new TypeKindVisitor6<TypeMirror, Void>() {

          @Override
          public TypeMirror visitDeclared(DeclaredType constraintValidatorImplementation, Void p) {
            // 2nd type parameter contains the data type supported by current validator class, e.g. "String"
            return constraintValidatorImplementation.getTypeArguments().get( 1 );
          }

        }, null
    );
  }
View Full Code Here

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

Examples of javax.lang.model.type.TypeMirror

    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

Examples of javax.lang.model.type.TypeMirror

      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

Examples of javax.lang.model.type.TypeMirror

      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

Examples of javax.lang.model.type.TypeMirror

    }
    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

Examples of javax.lang.model.type.TypeMirror

    }
  }

  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

Examples of javax.lang.model.type.TypeMirror

    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
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.