public class CastUtil extends Object
Constructor and Description |
---|
CastUtil() |
Modifier and Type | Method and Description |
---|---|
static <T> Collection<T> |
castDown(Collection<? super T> collection)
泛型集合向下转型。例如将Collection<Number>转换为Collection<Integer>
|
static <T> List<T> |
castDown(List<? super T> list)
泛型集合向下转型。例如将List<Number>转换为List<Integer>
|
static <K,V> Map<K,V> |
castDown(Map<? super K,? super V> map)
泛型集合向下转型。例如将Map<Number,Number>转换为Map<Integer, Integer>
|
static <T> Set<T> |
castDown(Set<? super T> set)
泛型集合向下转型。例如将Set<Number>转换为Set<Integer>
|
static <T> Collection<T> |
castUp(Collection<? extends T> collection)
泛型集合向上转型。例如将Collection<Integer>转换为Collection<Number>
|
static <T> List<T> |
castUp(List<? extends T> list)
泛型接口向上转型。例如将List<Integer>转换为List<Number>
|
static <K,V> Map<K,V> |
castUp(Map<? extends K,? extends V> map)
泛型集合向下转型。例如将Map<Integer, Integer>转换为Map<Number,Number>
|
static <T> Set<T> |
castUp(Set<? extends T> set)
泛型集合向上转型。例如将Set<Integer>转换为Set<Number>
|
public static <T> Collection<T> castUp(Collection<? extends T> collection)
T
- 元素类型collection
- 集合public static <T> Collection<T> castDown(Collection<? super T> collection)
T
- 元素类型collection
- 集合public static <T> Set<T> castUp(Set<? extends T> set)
T
- 泛型set
- 集合public static <T> Set<T> castDown(Set<? super T> set)
T
- 泛型子类set
- 集合public static <T> List<T> castUp(List<? extends T> list)
T
- 泛型的父类list
- 集合public static <T> List<T> castDown(List<? super T> list)
T
- 泛型的子类list
- 集合public static <K,V> Map<K,V> castUp(Map<? extends K,? extends V> map)
K
- 泛型父类V
- 泛型父类map
- 集合Copyright © 2024. All rights reserved.