Package javax.lang.model.type

Examples of javax.lang.model.type.TypeMirror


  }

  private AnnotationMetaAttribute createMetaCollectionAttribute(DeclaredType declaredType, Element element, String fqNameOfReturnType, String collection, String targetEntity) {
    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() );
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

  }

  private AnnotationMetaAttribute createAnnotationMetaAttributeForMap(DeclaredType declaredType, Element element, String collection, String targetEntity) {
    String keyType;
    if ( TypeUtils.containsAnnotation( element, MapKeyClass.class ) ) {
      TypeMirror typeMirror = (TypeMirror) TypeUtils.getAnnotationValue(
          TypeUtils.getAnnotationMirror(
              element, MapKeyClass.class
          ), TypeUtils.DEFAULT_ANNOTATION_PARAMETER_NAME
      );
      keyType = typeMirror.toString();
    }
    else {
      keyType = TypeUtils.getKeyType( declaredType, context );
    }
    return new AnnotationMetaMap(
View Full Code Here

    if ( targetEntity != null ) {
      return targetEntity;
    }
    final List<? extends TypeMirror> mirrors = declaredType.getTypeArguments();
    if ( mirrors.size() == 1 ) {
      final TypeMirror type = mirrors.get( 0 );
      return TypeUtils.extractClosestRealTypeAsString( type, context );
    }
    else if ( mirrors.size() == 2 ) {
      return TypeUtils.extractClosestRealTypeAsString( mirrors.get( 1 ), context );
    }
View Full Code Here

    assert parameterName != null;

    String targetEntityName = null;
    Object parameterValue = TypeUtils.getAnnotationValue( mirror, parameterName );
    if ( parameterValue != null ) {
      TypeMirror parameterType = (TypeMirror) parameterValue;
      if ( !parameterType.getKind().equals( TypeKind.VOID ) ) {
        targetEntityName = parameterType.toString();
      }
    }
    return targetEntityName;
  }
View Full Code Here

    return Boolean.TRUE;
  }

  @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

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

     * @param methodElement Method to look for parameters
     * @param parent The parent xml element to tack the results on
     */
    private void processParams(Document doc, ExecutableElement methodElement, Element parent) {
        for (VariableElement paramElement : methodElement.getParameters()) {
            TypeMirror t = paramElement.asType();
            if (skipParamType(t))
                continue;
            Element element = doc.createElement("param");
            parent.appendChild(element);
            // determine name
            String name;
            String paramType= BODY_INDICATOR;
            PathParam pp = paramElement.getAnnotation(PathParam.class);
            QueryParam qp = paramElement.getAnnotation(QueryParam.class);
            ApiParam ap = paramElement.getAnnotation(ApiParam.class);
            if (pp != null) {
                name = pp.value();
                paramType="Path";
            }
            else if (qp!=null) {
                name = qp.value();
                paramType="Query";
            }
            else if (ap!=null)
                name = ap.name();
            else {
                Name nameElement = paramElement.getSimpleName();
                name = nameElement.toString();
            }

            element.setAttribute("name", name);
            element.setAttribute("paramType",paramType);
            ApiParam apiParam = paramElement.getAnnotation(ApiParam.class);
            if (apiParam!=null) {
                String description = apiParam.value();
                setOptionalAttribute(element, "description", description);
                String required = String.valueOf(apiParam.required());
                if (pp!=null || paramType.equals(BODY_INDICATOR)) // PathParams are always required
                    required="true";

                setOptionalAttribute(element, "required", required, "false");
                String allowedValues = apiParam.allowableValues();
                setOptionalAttribute(element, "allowableValues", allowedValues, "all");
            }
            String defaultValue;
            DefaultValue dva = paramElement.getAnnotation(DefaultValue.class);
            if (dva!=null)
                defaultValue = dva.value();
            else if (ap!=null)
                defaultValue = ap.defaultValue();
            else
                defaultValue = "-none-";

            if (defaultValue!=null)
                element.setAttribute("defaultValue",defaultValue);

            String typeString = t.toString();
            constructTypeNameAndAssign(element, typeString, "type");
        }
    }
View Full Code Here

                mElem.setAttribute("name",pName);
                ApiProperty ap = m.getAnnotation(ApiProperty.class);
                if (ap!=null) {
                    mElem.setAttribute("description",ap.value());
                }
                TypeMirror returnTypeMirror = m.getReturnType();
                //  for types in the modelPackage or java.lang, remove the fqdn
                String typeName = returnTypeMirror.toString();
                if (typeName.contains(modelPackage)) {
                    typeName = typeName.replace(modelPackage+".","");
                }
                if (typeName.contains("java.lang.")) {
                    typeName = typeName.replaceAll("java\\.lang\\.", "");
View Full Code Here

    }

    ExecutableType clientMethod = viewIn(checkedElement, clientMethodElement, state);
    List<TypeMirror> lookFor = new ArrayList<TypeMirror>();
    // Convert client method signature to domain types
    TypeMirror returnType;
    try {
      returnType = convertToDomainTypes(clientMethod, lookFor, clientMethodElement, state);
    } catch (UnmappedTypeException e) {
      /*
       * Unusual: this would happen if a RequestContext for which we have a
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.