forked from json-iterator/java
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReflectionDecoderFactory.java
More file actions
31 lines (28 loc) · 990 Bytes
/
ReflectionDecoderFactory.java
File metadata and controls
31 lines (28 loc) · 990 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
28
29
30
31
package com.jsoniter;
import com.jsoniter.spi.ClassInfo;
import com.jsoniter.spi.Decoder;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.Map;
class ReflectionDecoderFactory {
public static Decoder create(ClassInfo classAndArgs) {
Class clazz = classAndArgs.clazz;
Type[] typeArgs = classAndArgs.typeArgs;
if (clazz.isArray()) {
return new ReflectionArrayDecoder(clazz);
}
if (Collection.class.isAssignableFrom(clazz)) {
return new ReflectionCollectionDecoder(clazz, typeArgs);
}
if (Map.class.isAssignableFrom(clazz)) {
return new ReflectionMapDecoder(clazz, typeArgs);
}
if (clazz.isEnum()) {
return new ReflectionEnumDecoder(clazz);
}
if (clazz.isRecord()) {
return new ReflectionRecordDecoder(classAndArgs).create();
}
return new ReflectionObjectDecoder(classAndArgs).create();
}
}