Package org.apache.solr.jersey
Class NullKeyTolerantMap
- All Implemented Interfaces:
com.fasterxml.jackson.databind.JsonSerializable,Serializable,Cloneable,Map<String,,Object> SequencedMap<String,Object>
public class NullKeyTolerantMap
extends LinkedHashMap<String,Object>
implements com.fasterxml.jackson.databind.JsonSerializable
A
Map that renders identically to a plain LinkedHashMap everywhere except through
Jackson.
org.apache.solr.core.PluginInfo#writeMap groups a plugin's unnamed children (e.g.
anonymous <processor> entries under an updateRequestProcessorChain) under a
null key. Solr's legacy (v1) JSON response writer tolerates that null key natively,
rendering it as "". Jackson, however, rejects null Map keys outright and (by default)
omits null-valued entries entirely.
Wrap a config/plugin-derived map in this class to let the v2/JAX-RS (Jackson) response path render a self-describing key in place of the null key and keep null values, without changing what any non-Jackson consumer (e.g. a v1 handler reading the same map instance) sees.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> Nested classes/interfaces inherited from interface com.fasterxml.jackson.databind.JsonSerializable
com.fasterxml.jackson.databind.JsonSerializable.Base -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidserialize(com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers) voidserializeWithType(com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers, com.fasterxml.jackson.databind.jsontype.TypeSerializer typeSer) Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, newLinkedHashMap, putFirst, putLast, removeEldestEntry, replaceAll, reversed, sequencedEntrySet, sequencedKeySet, sequencedValues, valuesMethods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from class java.util.AbstractMap
equals, hashCode, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from interface java.util.SequencedMap
firstEntry, lastEntry, pollFirstEntry, pollLastEntry
-
Constructor Details
-
NullKeyTolerantMap
- Parameters:
nullKeyReplacement- the JSON field name to substitute for anullMap key, wherever one is found (at any nesting depth of Maps/Lists reachable from this instance).
-
-
Method Details
-
serialize
public void serialize(com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers) throws IOException - Specified by:
serializein interfacecom.fasterxml.jackson.databind.JsonSerializable- Throws:
IOException
-
serializeWithType
public void serializeWithType(com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers, com.fasterxml.jackson.databind.jsontype.TypeSerializer typeSer) throws IOException - Specified by:
serializeWithTypein interfacecom.fasterxml.jackson.databind.JsonSerializable- Throws:
IOException
-