Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.fasterxml.jackson.databind.deser.impl;
import java.util.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.deser.std.StdDelegatingDeserializer;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.fasterxml.jackson.databind.util.Converter;
/**
* Helper class used to contain logic for deserializing "special" containers
* from {@code java.util.Collections} and {@code java.util.Arrays}. This is needed
* because they do not have usable no-arguments constructor: however, are easy enough
* to deserialize using delegating deserializer.
*
* @since 2.9.4
*/
public abstract class JavaUtilCollectionsDeserializers
{
private final static int TYPE_SINGLETON_SET = 1;
private final static int TYPE_SINGLETON_LIST = 2;
private final static int TYPE_SINGLETON_MAP = 3;
private final static int TYPE_UNMODIFIABLE_SET = 4;
private final static int TYPE_UNMODIFIABLE_LIST = 5;
private final static int TYPE_UNMODIFIABLE_MAP = 6;
// 2.12.1
private final static int TYPE_SYNC_SET = 7;
private final static int TYPE_SYNC_COLLECTION = 8;
private final static int TYPE_SYNC_LIST = 9;
private final static int TYPE_SYNC_MAP = 10;
public final static int TYPE_AS_LIST = 11;
private final static String PREFIX_JAVA_UTIL_COLLECTIONS = "java.util.Collections$";
private final static String PREFIX_JAVA_UTIL_ARRAYS = "java.util.Arrays$";
// for Java 11+ List.of(), Map.of() stuff
private final static String PREFIX_JAVA_UTIL_IMMUTABLE_COLL = "java.util.ImmutableCollections$";
public static JsonDeserializer> findForCollection(DeserializationContext ctxt,
JavaType type)
throws JsonMappingException
{
final String clsName = type.getRawClass().getName();
if (!clsName.startsWith("java.util.")) {
return null;
}
// 10-Jan-2017, tatu: Some types from `java.util.Collections`/`java.util.Arrays`
// need a bit of help...
String localName = _findUtilCollectionsTypeName(clsName);
if (localName != null) {
JavaUtilCollectionsConverter conv = null;
String name;
if ((name = _findUnmodifiableTypeName(localName)) != null) {
if (name.endsWith("Set")) {
conv = converter(TYPE_UNMODIFIABLE_SET, type, Set.class);
} else if (name.endsWith("List")) {
conv = converter(TYPE_UNMODIFIABLE_LIST, type, List.class);
}
} else if ((name = _findSingletonTypeName(localName)) != null) {
if (name.endsWith("Set")) {
conv = converter(TYPE_SINGLETON_SET, type, Set.class);
} else if (name.endsWith("List")) {
conv = converter(TYPE_SINGLETON_LIST, type, List.class);
}
} else if ((name = _findSyncTypeName(localName)) != null) {
// [databind#3009]: synchronized, too
if (name.endsWith("Set")) {
conv = converter(TYPE_SYNC_SET, type, Set.class);
} else if (name.endsWith("List")) {
conv = converter(TYPE_SYNC_LIST, type, List.class);
} else if (name.endsWith("Collection")) {
conv = converter(TYPE_SYNC_COLLECTION, type, Collection.class);
}
}
return (conv == null) ? null : new StdDelegatingDeserializer