Package com.sun.mirror.type

Examples of com.sun.mirror.type.TypeMirror


    public TypeMath(AnnotationProcessorEnvironment env) {
        this.env = env;
    }

    TypeMirror isCollection(TypeMirror t) {
        TypeMirror collectionType = baseClassFinder.apply(t, env.getTypeDeclaration(Collection.class.getName()));
        if(collectionType!=null) {
            DeclaredType d = (DeclaredType)collectionType;
            return d.getActualTypeArguments().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;
            String qn = dec.getDeclaration().getQualifiedName();
            return ( qn );
        }
View Full Code Here

    public boolean isArrayButNotByteArray(TypeMirror t) {
        if(!isArray(t))
            return false;

        ArrayType at = (ArrayType) t;
        TypeMirror ct = at.getComponentType();

        return !ct.equals(primitiveByte);
    }
View Full Code Here

                defaultNamespaceRemap );

        builder.setErrorHandler(new ErrorHandlerImpl(env.getMessager()));

        for( Reference ref : rootClasses ) {
            TypeMirror t = ref.type;

            XmlJavaTypeAdapter xjta = ref.annotations.getAnnotation(XmlJavaTypeAdapter.class);
            XmlList xl = ref.annotations.getAnnotation(XmlList.class);

            builder.getTypeInfo(new Ref<TypeMirror,TypeDeclaration>(builder,t,xjta,xl));
View Full Code Here

  public static MethodDeclaration findGetterForField( @NotNull ClassDeclaration classDeclaration, @NotNull @NonNls String simpleName, @NotNull TypeMirror type ) {
    String expectedName = "get" + simpleName.substring( 0, 1 ).toUpperCase() + simpleName.substring( 1 );

    for ( MethodDeclaration methodDeclaration : classDeclaration.getMethods() ) {
      if ( methodDeclaration.getSimpleName().equals( expectedName ) ) {
        TypeMirror returnType = methodDeclaration.getReturnType();
        if ( isAssignable( type, returnType ) ) {
          return methodDeclaration;
        } else {
          throw new IllegalArgumentException( "Invalid return types for <" + expectedName + ">. Was <" + returnType + "> but expected <" + type + ">" );
        }
View Full Code Here

    if ( TypeUtils.isType( type, Boolean.class ) ) {
      return codeModel.ref( Boolean.class ).staticRef( CONSTANT_NAME_TRUE );
    }

    if ( TypeUtils.isCollectionType( type ) ) {
      TypeMirror collectionParamType = TypeUtils.getCollectionParam( type );
      JExpression expression = create( TypeUtils.getErasure( collectionParamType ), simpleName );

      JInvocation listInvocation = classRefSupport.ref( Arrays.class ).staticInvoke( METHOD_NAME_AS_LIST ).arg( expression );
      if ( TypeUtils.isSetType( type ) ) {
        return JExpr._new( classRefSupport.ref( HashSet.class ) ).arg( listInvocation );
View Full Code Here

  }

  @NotNull
  public JClass ref( @NotNull TypeMirror type ) {
    if ( TypeUtils.isCollectionType( type ) ) {
      TypeMirror collectionParamType = TypeUtils.getCollectionParam( type );

      JClass collectionParam;
      if ( collectionParamType instanceof WildcardType ) {
        collectionParam = ref( TypeUtils.getErasure( collectionParamType ).toString() ).wildcard();
      } else {
        collectionParam = ref( collectionParamType.toString() );
      }

      JClass collection = ref( TypeUtils.getErasure( type ) );
      return collection.narrow( collectionParam );
    }
View Full Code Here

  public static MethodDeclaration findGetterForField( @NotNull ClassDeclaration classDeclaration, @NotNull @NonNls String simpleName, @NotNull TypeMirror type ) {
    String expectedName = NamingSupport.createGetterName( simpleName );

    for ( MethodDeclaration methodDeclaration : classDeclaration.getMethods() ) {
      if ( methodDeclaration.getSimpleName().equals( expectedName ) ) {
        TypeMirror returnType = methodDeclaration.getReturnType();
        if ( TypeUtils.isAssignable( type, returnType ) ) {
          return methodDeclaration;
        } else {
          throw new IllegalArgumentException( "Invalid return types for <" + expectedName + ">. Was <" + returnType + "> but expected <" + type + ">" );
        }
View Full Code Here

  @Nonnull
  public static MethodDeclaration findGetter( @Nonnull ClassDeclaration classDeclaration, @Nonnull TypeMirror type, @Nonnull String expectedName ) {
    for ( MethodDeclaration methodDeclaration : findMethodsIncludingSuperClass( classDeclaration ) ) {
      if ( methodDeclaration.getSimpleName().equals( expectedName ) ) {
        TypeMirror returnType = methodDeclaration.getReturnType();
        if ( isAssignable( type, returnType ) ) {
          return methodDeclaration;
        } else {
          throw new IllegalArgumentException( "Invalid return types for <" + expectedName + ">. Was <" + returnType + "> but expected <" + type + ">" );
        }
View Full Code Here

  }

  @Nullable
  private JClass refCollectionParam( @Nonnull TypeMirror collectionType ) {
    try {
      TypeMirror collectionParamType = TypeUtils.getCollectionParam( collectionType );
      if ( TypeUtils.isWildcardType( collectionParamType ) ) {
        return ref( TypeUtils.getErasure( collectionParamType ).toString() ).wildcard();
      } else {
        return ref( collectionParamType.toString() );
      }
    } catch ( NotFoundException ignore ) {
      return null;
    }
  }
View Full Code Here

TOP

Related Classes of com.sun.mirror.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.