|
7 | 7 | import com.fasterxml.jackson.core.type.TypeReference;
|
8 | 8 | import com.fasterxml.jackson.core.util.Snapshottable;
|
9 | 9 | import com.fasterxml.jackson.databind.JavaType;
|
| 10 | +import com.fasterxml.jackson.databind.JsonNode; |
10 | 11 | import com.fasterxml.jackson.databind.util.ArrayBuilders;
|
11 | 12 | import com.fasterxml.jackson.databind.util.ClassUtil;
|
12 | 13 | import com.fasterxml.jackson.databind.util.SimpleLookupCache;
|
@@ -65,6 +66,7 @@ public final class TypeFactory
|
65 | 66 | private final static Class<?> CLS_COMPARABLE = Comparable.class;
|
66 | 67 | private final static Class<?> CLS_CLASS = Class.class;
|
67 | 68 | private final static Class<?> CLS_ENUM = Enum.class;
|
| 69 | + private final static Class<?> CLS_JSON_NODE = JsonNode.class; // since 2.10 |
68 | 70 |
|
69 | 71 | private final static Class<?> CLS_BOOL = Boolean.TYPE;
|
70 | 72 | private final static Class<?> CLS_INT = Integer.TYPE;
|
@@ -106,6 +108,14 @@ public final class TypeFactory
|
106 | 108 | */
|
107 | 109 | protected final static SimpleType CORE_TYPE_CLASS = new SimpleType(CLS_CLASS);
|
108 | 110 |
|
| 111 | + /** |
| 112 | + * Cache {@link JsonNode} because it is no critical path of simple tree model |
| 113 | + * reading and does not have things to override |
| 114 | + * |
| 115 | + * @since 2.10 |
| 116 | + */ |
| 117 | + protected final static SimpleType CORE_TYPE_JSON_NODE = new SimpleType(CLS_JSON_NODE); |
| 118 | + |
109 | 119 | /**
|
110 | 120 | * Since type resolution can be expensive (specifically when resolving
|
111 | 121 | * actual generic types), we will use small cache to avoid repetitive
|
@@ -1120,6 +1130,7 @@ protected JavaType _findWellKnownSimple(Class<?> clz) {
|
1120 | 1130 | } else {
|
1121 | 1131 | if (clz == CLS_STRING) return CORE_TYPE_STRING;
|
1122 | 1132 | if (clz == CLS_OBJECT) return CORE_TYPE_OBJECT; // since 2.7
|
| 1133 | + if (clz == CLS_JSON_NODE) return CORE_TYPE_JSON_NODE; // since 2.10 |
1123 | 1134 | }
|
1124 | 1135 | return null;
|
1125 | 1136 | }
|
|
0 commit comments