add moshi

This commit is contained in:
Looly
2024-09-28 22:53:29 +08:00
parent 8eff63bc9f
commit 4db6ac1f34
12 changed files with 462 additions and 9 deletions

View File

@@ -312,7 +312,7 @@ public class TypeUtil {
* @since 4.5.2
*/
public static ParameterizedType toParameterizedType(Type type, final int interfaceIndex) {
if(type instanceof TypeReference){
if (type instanceof TypeReference) {
type = ((TypeReference<?>) type).getType();
}
@@ -473,6 +473,22 @@ public class TypeUtil {
return parameterizedType;
}
/**
* 创建泛型对象,例如:
*
* <pre>{@code
* List<String> list = TypeUtil.createParameterizedType(List.class, String.class);
* }</pre>
*
* @param rawType 原始类型例如List.class
* @param actualTypeArguments 实际类型例如String.class
* @return 泛型对象
* @since 6.0.0
*/
public static Type createParameterizedType(final Type rawType, final Type... actualTypeArguments) {
return new ParameterizedTypeImpl(actualTypeArguments, null, rawType);
}
/**
* 获得泛型变量对应的泛型实际类型如果此变量没有对应的实际类型返回null
*