Package javax.lang.model.type

Examples of javax.lang.model.type.DeclaredType


    static class MyProcessor extends AbstractProcessor {
        void test(TypeElement element, boolean fbound) {
            TypeParameterElement tpe = element.getTypeParameters().iterator().next();
            tpe.getBounds().getClass();
            if (fbound) {
                DeclaredType type = (DeclaredType)tpe.getBounds().get(0);
                if (type.asElement() != element)
                    throw error("%s != %s", type.asElement(), element);
                TypeVariable tv = (TypeVariable)type.getTypeArguments().get(0);
                if (tv.asElement() != tpe)
                    throw error("%s != %s", tv.asElement(), tpe);
            }
        }
View Full Code Here


            }
            ExecutableElement method = (ExecutableElement)annoElement;
            if (method.getParameters().size() != 2) {
                error("annotated method must have 2 arguments");
            }
            DeclaredType d1 = (DeclaredType)method.getParameters().get(0).asType();
            DeclaredType d2 = (DeclaredType)method.getParameters().get(1).asType();
            if (d1.getTypeArguments().size() != 1 ||
                    d1.getTypeArguments().size() != 1) {
                error("parameter type must be generic in one type-variable");
            }
            TypeMirror t1 = d1.getTypeArguments().get(0);
            TypeMirror t2 = d2.getTypeArguments().get(0);

            if (processingEnv.getTypeUtils().contains(t1, t2) != expected) {
                error("bad type containment result\n" +
                        "t1 : " + t1 +"\n" +
                        "t2 : " + t2 +"\n" +
View Full Code Here

    Class<?> wrapper = PRIMITIVE_WRAPPERS.get(type.getKind());
    if (wrapper != null) {
      return wrapper.getName();
    }
    if (type instanceof DeclaredType) {
      DeclaredType declaredType = (DeclaredType) type;
      Element enclosingElement = declaredType.asElement().getEnclosingElement();
      if (enclosingElement != null && enclosingElement instanceof TypeElement) {
        return getType(enclosingElement) + "$"
            + declaredType.asElement().getSimpleName().toString();
      }
    }
    return type.toString();
  }
View Full Code Here

      if ( !elem.getSimpleName().toString().equals( propertyName ) ) {
        continue;
      }

      DeclaredType type = ( ( DeclaredType ) elem.asType() );
      determineTargetType( type, propertyName, explicitTargetEntity, types );
      determineCollectionType( type, types );
      if ( types[1].equals( "javax.persistence.metamodel.MapAttribute" ) ) {
        determineMapType( type, explicitMapKeyClass, types );
      }
View Full Code Here

    return annotationApiHelper.keepLowestTypePerHierarchy( theValue );
  }

  private void registerAllowedTypesForBuiltInConstraint(String annotationType, Class<?>... allowedTypes) {

    DeclaredType annotation = annotationApiHelper.getDeclaredTypeByName( annotationType );

    if ( annotation == null ) {
      return;
    }
View Full Code Here

    }
  }

  private void registerAllowedTypesForBuiltInConstraintByNames(String annotationType, String... allowedTypes) {

    DeclaredType annotation = annotationApiHelper.getDeclaredTypeByName( annotationType );

    if ( annotation == null ) {
      return;
    }
View Full Code Here

      if ( !elem.getSimpleName().toString().equals( propertyName ) ) {
        continue;
      }

      DeclaredType type = ( ( DeclaredType ) elem.asType() );
      determineTargetType( type, propertyName, explicitTargetEntity, types );
      determineCollectionType( type, types );
      if ( types[1].equals( "javax.persistence.metamodel.MapAttribute" ) ) {
        determineMapType( type, explicitMapKeyClass, types );
      }
View Full Code Here

      if ( !propertyName.equals( elementPropertyName ) ) {
        continue;
      }

      DeclaredType type = determineDeclaredType( elem );
      if ( type == null ) {
        continue;
      }

      return determineTypes( propertyName, explicitTargetEntity, explicitMapKeyClass, type );
View Full Code Here

  private String[] getCollectionType(String propertyName) {
    String types[] = new String[2];
    for ( Element elem : element.getEnclosedElements() ) {
      if ( elem.getSimpleName().toString().equals( propertyName ) ) {
        DeclaredType type = ( ( DeclaredType ) elem.asType() );
        types[0] = type.getTypeArguments().get( 0 ).toString();
        types[1] = COLLECTIONS.get( type.asElement().toString() );
      }
    }
    return types;
  }
View Full Code Here

    }

    public Map<MethodSymbol, Attribute> getElementValuesWithDefaults(
              AnnotationMirror a) {
  Attribute.Compound anno = cast(Attribute.Compound.class, a);
  DeclaredType annotype = a.getAnnotationType();
  Map<MethodSymbol, Attribute> valmap = anno.getElementValues();

  for (ExecutableElement ex :
     methodsIn(annotype.asElement().getEnclosedElements())) {
      MethodSymbol meth = (MethodSymbol) ex;
      Attribute defaultValue = meth.getDefaultValue();
      if (defaultValue != null && !valmap.containsKey(meth)) {
    valmap.put(meth, defaultValue);
      }
View Full Code Here

TOP

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

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.