Package javax.lang.model.type

Examples of javax.lang.model.type.DeclaredType


    }
    return null;
  }

  private DeclaredType determineDeclaredType(Element elem) {
    DeclaredType type = null;
    if ( elem.asType() instanceof DeclaredType ) {
      type = ( (DeclaredType) elem.asType() );
    }
    else if ( elem.asType() instanceof ExecutableType ) {
      ExecutableType executableType = (ExecutableType) elem.asType();
View Full Code Here


    registerAllowedTypesForBuiltInConstraint( annotationType, asMirrors( typeNames ) );
  }

  private void registerAllowedTypesForBuiltInConstraint(String annotationType, List<TypeMirror> supportedTypes) {

    DeclaredType annotation = annotationApiHelper.getDeclaredTypeByName( annotationType );

    if ( annotation == null ) {
      return;
    }
    Name key = getName( annotation );
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

      if (rt.getKind() != TypeKind.DECLARED) {
        warn("Field " + elementAsString(element)
            + "\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

      if (rt.getKind() != TypeKind.DECLARED) {
        warn("Method " + elementAsString(element)
            + "\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);
        }
      }
      if (ee.getParameters().size() != 0) {
        warn("Method "
View Full Code Here

  }

  /** @return type represents a Throwable type (e.g. Exception, Error) **/
  public static boolean isThrowable(TypeMirror type) {
    while (type != null && type.getKind() == TypeKind.DECLARED) {
      DeclaredType dt = (DeclaredType) type;
      TypeElement elem = (TypeElement) dt.asElement();
      Name name = elem.getQualifiedName();
      if ("java.lang.Throwable".contentEquals(name)) {
        return true;
      }
      type = elem.getSuperclass();
View Full Code Here

      return js.keyword(Keyword.NULL);
    }
    JS typeName = js.string(context.getNames().getTypeName(context, type));

    if (type instanceof DeclaredType) {
      DeclaredType declaredType = (DeclaredType) type;

      // enum
      if (declaredType.asElement().getKind() == ElementKind.ENUM) {
        return js.object(Arrays.asList(NameValue.of("name", js.string("Enum")),
            NameValue.of("arguments", js.array(Collections.singleton(typeName)))));
      }
      // parametrized type
      if (!declaredType.getTypeArguments().isEmpty()) {
        List<JS> array = new ArrayList<JS>();
        for (TypeMirror arg : declaredType.getTypeArguments()) {
          array.add(getFieldTypeDesc(arg, context));
        }
        return js.object(Arrays.asList(NameValue.of("name", typeName), NameValue.of("arguments", js.array(array))));
      }
View Full Code Here

  public static boolean sameRawType(TypeMirror type1, Class<?> clazz) {
    if (!(type1 instanceof DeclaredType)) {
      return false;
    }
    DeclaredType declType1 = (DeclaredType) type1;
    return clazz.getName().equals(((TypeElement) declType1.asElement()).getQualifiedName().toString());
  }
View Full Code Here

  public static DeclaredType getEnclosingType(TypeMirror type) {
    if (!(type instanceof DeclaredType)) {
      return null;
    }
    DeclaredType declaredType = (DeclaredType) type;

    TypeMirror enclosingType = declaredType.asElement().getEnclosingElement().asType();
    if (enclosingType instanceof ExecutableType) {
      // get the type that encloses this method
      enclosingType = declaredType.asElement().getEnclosingElement().getEnclosingElement().asType();
    }
    if (enclosingType instanceof DeclaredType) {
      return (DeclaredType) enclosingType;
    }
    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.