Package javax.lang.model.type

Examples of javax.lang.model.type.DeclaredType


    public Set<? extends Element> getElementsAnnotatedWith(TypeElement a) {
  Set<Element> result = Collections.emptySet();
  if (a.getKind() != ElementKind.ANNOTATION_TYPE)
      throw new IllegalArgumentException(NOT_AN_ANNOTATION_TYPE + a);
 
  DeclaredType annotationTypeElement;
  TypeMirror tm = a.asType();
  if ( tm instanceof DeclaredType )
      annotationTypeElement = (DeclaredType) a.asType();
  else
      throw new AssertionError("Bad implementation type for " + tm);
View Full Code Here


    return annotationApiHelper.keepLowestTypePerHierarchy( theValue );
  }

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

    DeclaredType annotation = annotationApiHelper.getDeclaredTypeByName( annotationType );

    Set<TypeMirror> allowedTypesForConstraint = getSupportedTypesForBuiltInConstraint( annotation );

    for ( Class<?> oneAllowedType : allowedTypes ) {
      allowedTypesForConstraint.add( annotationApiHelper.getMirrorForType( oneAllowedType ) );
View Full Code Here

    }
  }

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

    DeclaredType annotation = annotationApiHelper.getDeclaredTypeByName( annotationType );

    Set<TypeMirror> allowedTypesForConstraint = getSupportedTypesForBuiltInConstraint( annotation );

    for ( String oneAllowedType : allowedTypes ) {
      allowedTypesForConstraint.add( annotationApiHelper.getDeclaredTypeByName( oneAllowedType ) );
View Full Code Here

    if (fullName != null) {
      return fullName;
    }

    if (type instanceof DeclaredType) {
      DeclaredType declaredType = (DeclaredType) type;
      String name = InternalUtils.getSimpleName(declaredType.asElement());
      Element rootTypeElement = declaredType.asElement();
      for (DeclaredType enclosingType = JavaNodes.getEnclosingType(declaredType); enclosingType != null; enclosingType =
          JavaNodes.getEnclosingType(enclosingType)) {
        rootTypeElement = enclosingType.asElement();
        name = InternalUtils.getSimpleName(rootTypeElement) + "." + name;
      }
View Full Code Here

      return CollectionHelper.asSet(
          new ConstraintCheckError( element, null, "CONSTRAINT_TYPE_MUST_DECLARE_GROUPS_MEMBER" )
      );
    }

    DeclaredType type = getComponentTypeOfArrayReturnType( groupsMethod );

    if ( type == null ) {
      return CollectionHelper.asSet(
          new ConstraintCheckError( groupsMethod, null, "RETURN_TYPE_MUST_BE_CLASS_ARRAY" )
      );
    }

    boolean typeHasNameClass = type.asElement().getSimpleName().contentEquals( "Class" );
    boolean typeHasExactlyOneTypeArgument = type.getTypeArguments().size() == 1;
    boolean typeArgumentIsUnboundWildcard = validateWildcardBounds( type.getTypeArguments().get( 0 ), null, null );

    if ( !( typeHasNameClass && typeHasExactlyOneTypeArgument && typeArgumentIsUnboundWildcard ) ) {
      return CollectionHelper.asSet(
          new ConstraintCheckError( groupsMethod, null, "RETURN_TYPE_MUST_BE_CLASS_ARRAY" )
      );
View Full Code Here

      return CollectionHelper.asSet(
          new ConstraintCheckError( element, null, "CONSTRAINT_TYPE_MUST_DECLARE_PAYLOAD_MEMBER" )
      );
    }

    DeclaredType type = getComponentTypeOfArrayReturnType( payloadMethod );

    if ( type == null ) {
      return CollectionHelper.asSet(
          new ConstraintCheckError( payloadMethod, null, "PAYLOAD_RETURN_TYPE_MUST_BE_CLASS_ARRAY" )
      );
    }

    boolean typeHasNameClass = type.asElement().getSimpleName().contentEquals( "Class" );
    boolean typeHasExactlyOneTypeArgument = type.getTypeArguments().size() == 1;
    boolean typeArgumentIsWildcardWithPayloadExtendsBound = validateWildcardBounds(
        type.getTypeArguments().get( 0 ),
        annotationApiHelper.getDeclaredTypeByName( BeanValidationTypes.PAYLOAD ),
        null
    );

    if ( !( typeHasNameClass && typeHasExactlyOneTypeArgument && typeArgumentIsWildcardWithPayloadExtendsBound ) ) {
View Full Code Here

        private String toString(AnnotationValue value) {
            if (value.getValue() instanceof TypeMirror) {
                TypeMirror tm = (TypeMirror) value.getValue();
                if (tm.getKind().equals(TypeKind.DECLARED)) {
                    DeclaredType dt = (DeclaredType) tm;
                    return getClassName((TypeElement) dt.asElement());
                }
            }
            return value.toString();
        }
View Full Code Here

    }

    TypeMirror isCollection(TypeMirror t) {
        TypeMirror collectionType = baseClassFinder.visit(t, env.getElementUtils().getTypeElement(Collection.class.getName()));
        if (collectionType != null) {
            DeclaredType d = (DeclaredType) collectionType;
            return d.getTypeArguments().iterator().next();
        } else
            return null;
    }
View Full Code Here

    }

    private static String getCanonicalTypeFrom(MirroredTypeException me) {
        TypeMirror tm = me.getTypeMirror();
        if (tm instanceof DeclaredType) {
            DeclaredType dec = (DeclaredType) tm;
            return ((TypeElement)dec.asElement()).getQualifiedName().toString();
        }
        return ""//ok?
    }
View Full Code Here

                }

                TypeMirror mapType = math.baseClassFinder.visit(type, processingEnv.getElementUtils().getTypeElement(Map.class.getName()));
                if(mapType!=null) {
                    // T=Map<...>
                    DeclaredType d = (DeclaredType)mapType;
                    List<? extends TypeMirror> itr = d.getTypeArguments();
                    return new MapPacker(itr.get(1));
                }

                return null;
            }
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.