Package com.sun.mirror.type

Examples of com.sun.mirror.type.TypeMirror


  @NotNull
  public static MethodDeclaration findGetter( @NotNull ClassDeclaration classDeclaration, @NotNull TypeMirror type, @NonNls 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( @NotNull 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

    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

        public String toString() {
            return ex.getQualifiedName();
        }

        public int hashCode() {
            TypeMirror t = ex.getTypeMirror();
            return (t != null)
                    ? t.hashCode()
                    : ex.getQualifiedName().hashCode();
        }
View Full Code Here

                    ? t.hashCode()
                    : ex.getQualifiedName().hashCode();
        }

        public boolean equals(Object obj) {
            TypeMirror t = ex.getTypeMirror();
            return t != null &&
                   obj instanceof MirroredTypeExceptionProxy &&
                   t.equals(
                        ((MirroredTypeExceptionProxy) obj).ex.getTypeMirror());
        }
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 = "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

  @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

                if(erasure instanceof ArrayType) {
                    // T=X[]
                    return new ArrayPacker((ArrayType)erasure);
                }

                TypeMirror itemType = math.isCollection(type);
                if(itemType!=null) {
                    // T=Collection[]
                    return new ListPacker(type,itemType);
                }

                TypeMirror mapType = TypeMath.baseClassFinder.apply(type, env.getTypeDeclaration(Map.class.getName()));
                if(mapType!=null) {
                    // T=Map<...>
                    DeclaredType d = (DeclaredType)mapType;
                    Iterator<TypeMirror> itr = d.getActualTypeArguments().iterator();
                    itr.next();
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.