forked from json-iterator/java
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClassInfo.java
More file actions
27 lines (23 loc) · 763 Bytes
/
ClassInfo.java
File metadata and controls
27 lines (23 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.jsoniter.spi;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.WildcardType;
public class ClassInfo {
public final Type type;
public final Class clazz;
public final Type[] typeArgs;
public ClassInfo(Type type) {
this.type = type;
if (type instanceof ParameterizedType) {
ParameterizedType pType = (ParameterizedType) type;
clazz = (Class) pType.getRawType();
typeArgs = pType.getActualTypeArguments();
} else if (type instanceof WildcardType) {
clazz = Object.class;
typeArgs = new Type[0];
} else {
clazz = (Class) type;
typeArgs = new Type[0];
}
}
}