Skip to content

Commit

Permalink
Add TypeFactory.createDefaultInstance()
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Oct 13, 2024
1 parent 1643c1e commit 4a40123
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/main/java/com/fasterxml/jackson/databind/type/TypeFactory.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package com.fasterxml.jackson.databind.type;

import java.lang.reflect.Array;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.lang.reflect.*;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.BaseStream;
Expand All @@ -18,10 +13,7 @@

import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.util.ArrayBuilders;
import com.fasterxml.jackson.databind.util.ClassUtil;
import com.fasterxml.jackson.databind.util.LRUMap;
import com.fasterxml.jackson.databind.util.LookupCache;
import com.fasterxml.jackson.databind.util.*;

/**
* Class used for creating concrete {@link JavaType} instances,
Expand Down Expand Up @@ -70,7 +62,6 @@
* </li>
*</ul>
*/
@SuppressWarnings({"rawtypes" })
public class TypeFactory // note: was final in 2.9, removed from 2.10
implements java.io.Serializable
{
Expand All @@ -79,8 +70,6 @@ public class TypeFactory // note: was final in 2.9, removed from 2.10
/**
* Default size used to construct {@link #_typeCache}.
*
* Used to be passed inline.
*
* @since 2.16
*/
public static final int DEFAULT_MAX_CACHE_SIZE = 200;
Expand Down Expand Up @@ -222,6 +211,14 @@ protected TypeFactory(LookupCache<Object,JavaType> typeCache, TypeParser p,
_classLoader = classLoader;
}

/**
* Method used to construct a new default/standard {@code TypeFactory}
* instance; an instance which has no custom configuration.
*
* @since 2.19
*/
public static TypeFactory createDefaultInstance() { return new TypeFactory(); }

/**
* "Mutant factory" method which will construct a new instance with specified
* {@link TypeModifier} added as the first modifier to call (in case there
Expand Down Expand Up @@ -923,6 +920,7 @@ public ArrayType constructArrayType(JavaType elementType) {
* NOTE: type modifiers are NOT called on Collection type itself; but are called
* for contained types.
*/
@SuppressWarnings({"rawtypes" })
public CollectionType constructCollectionType(Class<? extends Collection> collectionClass,
Class<?> elementClass) {
return constructCollectionType(collectionClass,
Expand All @@ -935,6 +933,7 @@ public CollectionType constructCollectionType(Class<? extends Collection> collec
* NOTE: type modifiers are NOT called on Collection type itself; but are called
* for contained types.
*/
@SuppressWarnings({"rawtypes" })
public CollectionType constructCollectionType(Class<? extends Collection> collectionClass,
JavaType elementType)
{
Expand Down Expand Up @@ -986,6 +985,7 @@ public CollectionLikeType constructCollectionLikeType(Class<?> collectionClass,
* NOTE: type modifiers are NOT called on constructed type itself; but are called
* for contained types.
*/
@SuppressWarnings({"rawtypes" })
public MapType constructMapType(Class<? extends Map> mapClass,
Class<?> keyClass, Class<?> valueClass) {
JavaType kt, vt;
Expand All @@ -1003,6 +1003,7 @@ public MapType constructMapType(Class<? extends Map> mapClass,
*<p>
* NOTE: type modifiers are NOT called on constructed type itself.
*/
@SuppressWarnings({"rawtypes" })
public MapType constructMapType(Class<? extends Map> mapClass, JavaType keyType, JavaType valueType) {
TypeBindings bindings = TypeBindings.createIfNeeded(mapClass, new JavaType[] { keyType, valueType });
MapType result = (MapType) _fromClass(null, mapClass, bindings);
Expand Down Expand Up @@ -1232,6 +1233,7 @@ public JavaType constructParametrizedType(Class<?> parametrized, Class<?> parame
*<p>
* This method should only be used if parameterization is completely unavailable.
*/
@SuppressWarnings({"rawtypes" })
public CollectionType constructRawCollectionType(Class<? extends Collection> collectionClass) {
return constructCollectionType(collectionClass, unknownType());
}
Expand Down Expand Up @@ -1262,6 +1264,7 @@ public CollectionLikeType constructRawCollectionLikeType(Class<?> collectionClas
*<p>
* This method should only be used if parameterization is completely unavailable.
*/
@SuppressWarnings({"rawtypes" })
public MapType constructRawMapType(Class<? extends Map> mapClass) {
return constructMapType(mapClass, unknownType(), unknownType());
}
Expand Down

0 comments on commit 4a40123

Please sign in to comment.