Package javax.lang.model.type

Examples of javax.lang.model.type.TypeMirror


    public ArrayType convert(javax.lang.model.type.ArrayType type) {
        if (type == null) {
            throw new IllegalArgumentException("type must not be null"); //$NON-NLS-1$
        }
        int dimensions = 1;
        TypeMirror component = type.getComponentType();
        while (component.getKind() == TypeKind.ARRAY) {
            component = ((javax.lang.model.type.ArrayType) component).getComponentType();
            dimensions++;
        }
        Type result = convert0(component);
        if (result == null) {
View Full Code Here


     */
    public Wildcard convert(WildcardType type) {
        if (type == null) {
            throw new IllegalArgumentException("type must not be null"); //$NON-NLS-1$
        }
        TypeMirror upper = type.getExtendsBound();
        if (upper != null) {
            if (type.getSuperBound() != null) {
                return null;
            }
            Type bound = convert0(upper);
            if (bound == null) {
                return null;
            }
            return factory.newWildcard(WildcardBoundKind.UPPER_BOUNDED, bound);
        }
        TypeMirror lower = type.getSuperBound();
        if (lower != null) {
            Type bound = convert0(lower);
            if (bound == null) {
                return null;
            }
View Full Code Here

                    i,
                    keys.get(i));
        }
        for (int i = startResults; i < startParameters; i++) {
            TypeConstraint outputType = a.getParameterType(i).getTypeArgument();
            TypeMirror outputTypeMirror = outputType.getType();
            String found = builder.findInput(outputTypeMirror);
            if (found == null && outputType.isProjectiveModel()) {
                a.error("出力型{0}に対する入力が見つかりません", outputTypeMirror);
            }
            builder.addOutput(
View Full Code Here

        writer.println("<h1>" + title + "</h1>");

        showDocumentationAndFieldInjections(writer, roundEnv, classElement, "");

        // This code is not my fault, it seems to honestly be the hacky way to find a class name in APT :)
        TypeMirror consumerType = null;
        try {
            uriEndpoint.consumerClass();
        } catch (MirroredTypeException mte) {
            consumerType = mte.getTypeMirror();
        }

        boolean found = false;
        String consumerClassName = null;
        String consumerPrefix = Strings.getOrElse(uriEndpoint.consumerPrefix(), "");
        if (consumerType != null) {
            consumerClassName = consumerType.toString();
            TypeElement consumerElement = findTypeElement(roundEnv, consumerClassName);
            if (consumerElement != null) {
                writer.println("<h2>" + scheme + " consumer" + "</h2>");
                showDocumentationAndFieldInjections(writer, roundEnv, consumerElement, consumerPrefix);
                found = true;
View Full Code Here

                    if (Strings.isNullOrEmpty(name)) {
                        name = fieldName;
                    }
                    name = prefix + name;
                    // if the field type is a nested parameter then iterate through its fields
                    TypeMirror fieldType = fieldElement.asType();
                    String fieldTypeName = fieldType.toString();
                    TypeElement fieldTypeElement = findTypeElement(roundEnv, fieldTypeName);
                    UriParams fieldParams = null;
                    if (fieldTypeElement != null) {
                        fieldParams = fieldTypeElement.getAnnotation(UriParams.class);
                    }
                    if (fieldParams != null) {
                        String nestedPrefix = prefix;
                        String extraPrefix = fieldParams.prefix();
                        if (!Strings.isNullOrEmpty(extraPrefix)) {
                            nestedPrefix += extraPrefix;
                        }
                        findClassProperties(roundEnv, sortedMap, fieldTypeElement, nestedPrefix);
                    } else {
                        String docComment = elementUtils.getDocComment(fieldElement);
                        if (Strings.isNullOrEmpty(docComment)) {
                            String setter = "set" + fieldName.substring(0, 1).toUpperCase();
                            if (fieldName.length() > 1) {
                                setter += fieldName.substring(1);
                            }
                            //  lets find the setter
                            List<ExecutableElement> methods = ElementFilter.methodsIn(classElement.getEnclosedElements());
                            for (ExecutableElement method : methods) {
                                String methodName = method.getSimpleName().toString();
                                if (setter.equals(methodName) && method.getParameters().size() == 1) {
                                    String doc = elementUtils.getDocComment(method);
                                    if (!Strings.isNullOrEmpty(doc)) {
                                        docComment = doc;
                                        break;
                                    }
                                }
                            }
                        }
                        if (docComment == null) {
                            docComment = "";
                        }
                        List<String> values = new ArrayList<String>();
                        values.add("    <td>" + fieldTypeName + "</td>");
                        values.add("    <td>" + docComment.trim() + "</td>");

                        // TODO would be nice here to create a default endpoint/consumer object
                        // and return the default value of the field so we can put it into the docs
                        Object defaultValue = null;
                        if (defaultValue != null) {
                            values.add("    <td>" + defaultValue + "</td>");
                        }
                        if (sortedMap.containsKey(name)) {
                            error("Duplicate parameter annotation named '" + name + "' on class " + classElement.getQualifiedName());
                        } else {
                            sortedMap.put(name, values);
                        }
                    }
                }
            }
            TypeElement baseTypeElement = null;
            TypeMirror superclass = classElement.getSuperclass();
            if (superclass != null) {
                String superClassName = canonicalClassName(superclass.toString());
                baseTypeElement = findTypeElement(roundEnv, superClassName);
            }
            if (baseTypeElement != null) {
                classElement = baseTypeElement;
            } else {
View Full Code Here

  }

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

    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 ( context.getMetaEntitiesToProcess().containsKey( superClassName )
          || context.getMetaSuperclassAndEmbeddableToProcess().containsKey( superClassName ) ) {
View Full Code Here

    }
    return type.toString();
  }

  static public 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();
      final Types types = context.getProcessingEnvironment().getTypeUtils();
      final List<? extends TypeMirror> upperBounds = types.directSupertypes( compositeUpperBound );
      if ( upperBounds.size() == 0 ) {
        return compositeUpperBound.toString();
      }
      else {
        //take the first one
        return extractClosestRealTypeAsString( upperBounds.get( 0 ), 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

    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

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.