Package javax.lang.model.element

Examples of javax.lang.model.element.TypeElement.asType()


  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();
    }
    else {
      List<? extends TypeMirror> typeArguments = t.getTypeArguments();
      if ( typeArguments.size() == 0 ) {
        throw new MetaModelGenerationException( "Unable to determine collection type" );
View Full Code Here


    for ( AnnotationMirror oneAnnotationMirror : annotationMirrors ) {

      if ( typeUtils.isSameType(
          oneAnnotationMirror.getAnnotationType(),
          typeElement.asType()
      ) ) {
        return oneAnnotationMirror;
      }
    }
View Full Code Here

            + "\n\tis prefixed with @Rule and is " + rt
            + "\n\tA rule field must be " + testRule);
      } else {
        DeclaredType dt = (DeclaredType) rt;
        if (!processingEnv.getTypeUtils().isSubtype(
            dt.asElement().asType(), testRule.asType())) {
          warn("Field " + elementAsString(element)
              + "\n\tis prefixed with @Rule and is "
              + dt.asElement().asType()
              + "\n\tA rule field must be " + testRule);
        }
View Full Code Here

            + "\n\tis prefixed with @Parameters and return " + rt
            + "\n\tThe parameters method must return " + stream);
      } else {
        DeclaredType dt = (DeclaredType) rt;
        if (!processingEnv.getTypeUtils().isSubtype(
            dt.asElement().asType(), stream.asType())) {
          warn("Method " + elementAsString(element)
              + "\n\tis prefixed with @Parameters and return "
              + dt.asElement().asType()
              + "\n\tThe parameters method must return " + stream);
        }
View Full Code Here

      TypeElement element = elements.getTypeElement(clazz.getCanonicalName());
      if (element == null) {
        ErrorReporter.errorAbort("Unrecognized class: " + clazz);
        return null; // dead code
      }
      return element.asType();
    }
  }

  /**
   * Returns an {@link ArrayType} with elements of type {@code componentType}.
View Full Code Here

    TypeElement typeElement = (TypeElement) methodElement.getEnclosingElement();

    String methodName = MethodInvocationWriter.buildMethodName(tree);

    // avoid useless call to super() when the super class is Object
    if (GeneratorConstants.SUPER.equals(methodName) && JavaNodes.sameRawType(typeElement.asType(), Object.class)) {
      return null;
    }

    // avoid call to super for synthetic types
    if (GeneratorConstants.SUPER.equals(methodName) && context.getCurrentWrapper().getEnclosingType().isSyntheticType()) {
View Full Code Here

      throw new RuntimeException(String.format("Unexpected kind of type parameter for %s: %s",
          typeParamEl.getSimpleName(), typeParam.getKind()));
    }
    TypeVariable tv = (TypeVariable) typeParam;
    TypeElement objectElem = elements.getTypeElement(Object.class.getName());
    return types.isSameType(objectElem.asType(), tv.getUpperBound());
  }

  /**
   * Returns <code>true</code> if the given string is a valid Java identifier.
   *
 
View Full Code Here

  }

  private boolean isGeneratePojoBuilderAnnotation(AnnotationMirror anno) {
    TypeElement generatePojoBuilderTypeEl =
        elements.getTypeElement(GeneratePojoBuilder.class.getName());
    return types.isSameType(anno.getAnnotationType(), generatePojoBuilderTypeEl.asType());
  }

  private Map<String, Object> getValueMap(List<HierarchyElement> hierarchy) {
    Map<String, Object> result = null;
    for (HierarchyElement el : hierarchy) {
View Full Code Here

    return new Input(methodEl, pojoTypeEl, (DeclaredType) pojoTypeMirror, directives, orginatingElements);
  }

  private Input getInputForAnnotatedConstructor(ExecutableElement constrEl) {
    TypeElement pojoTypeEl = (TypeElement) constrEl.getEnclosingElement();
    TypeMirror pojoTypeMirror = pojoTypeEl.asType();
    Set<Element> orginatingElements = new HashSet<Element>();
    Directives directives = directivesFactory.getDirectives(constrEl, orginatingElements);
    return new Input(constrEl, pojoTypeEl, (DeclaredType) pojoTypeMirror, directives, orginatingElements);
  }
View Full Code Here

    scanGetterMethods(input, output);
  }

  private void scanSetterMethods(Input input, Output output) {
    TypeElement pojoTypeEl = input.getPojoElement();
    DeclaredType pojoClassType = (DeclaredType) pojoTypeEl.asType();
    List<? extends Element> memberEls = elements.getAllMembers(pojoTypeEl);
    // loop over all setter methods
    List<ExecutableElement> methodEls = ElementFilter.methodsIn(memberEls);
    for (ExecutableElement methodEl : methodEls) {
      if (!javaModelAnalyzerUtil.isStatic(methodEl) && javaModelAnalyzerUtil.isSetterMethod(methodEl)
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.