// // Source code recreated from a .class file by IntelliJ IDEA // (powered by Fernflower decompiler) // package com.fasterxml.jackson.databind; import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Value; import com.fasterxml.jackson.annotation.JsonTypeInfo.As; import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; import com.fasterxml.jackson.core.Base64Variant; import com.fasterxml.jackson.core.Base64Variants; import com.fasterxml.jackson.core.FormatSchema; import com.fasterxml.jackson.core.JsonEncoding; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.core.PrettyPrinter; import com.fasterxml.jackson.core.TreeNode; import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.core.Versioned; import com.fasterxml.jackson.core.JsonFactory.Feature; import com.fasterxml.jackson.core.io.CharacterEscapes; import com.fasterxml.jackson.core.io.SegmentedStringWriter; import com.fasterxml.jackson.core.type.ResolvedType; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.util.ByteArrayBuilder; import com.fasterxml.jackson.databind.Module.SetupContext; import com.fasterxml.jackson.databind.cfg.BaseSettings; import com.fasterxml.jackson.databind.cfg.ConfigOverrides; import com.fasterxml.jackson.databind.cfg.ContextAttributes; import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; import com.fasterxml.jackson.databind.cfg.MutableConfigOverride; import com.fasterxml.jackson.databind.cfg.PackageVersion; import com.fasterxml.jackson.databind.deser.BeanDeserializerFactory; import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier; import com.fasterxml.jackson.databind.deser.DefaultDeserializationContext; import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler; import com.fasterxml.jackson.databind.deser.DeserializerFactory; import com.fasterxml.jackson.databind.deser.Deserializers; import com.fasterxml.jackson.databind.deser.KeyDeserializers; import com.fasterxml.jackson.databind.deser.ValueInstantiators; import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.introspect.BasicClassIntrospector; import com.fasterxml.jackson.databind.introspect.ClassIntrospector; import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver; import com.fasterxml.jackson.databind.introspect.VisibilityChecker; import com.fasterxml.jackson.databind.introspect.ClassIntrospector.MixInResolver; import com.fasterxml.jackson.databind.introspect.VisibilityChecker.Std; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsonschema.JsonSchema; import com.fasterxml.jackson.databind.jsontype.NamedType; import com.fasterxml.jackson.databind.jsontype.SubtypeResolver; import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.impl.StdSubtypeResolver; import com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.POJONode; import com.fasterxml.jackson.databind.node.TreeTraversingParser; import com.fasterxml.jackson.databind.ser.BeanSerializerFactory; import com.fasterxml.jackson.databind.ser.BeanSerializerModifier; import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider; import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.ser.SerializerFactory; import com.fasterxml.jackson.databind.ser.Serializers; import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.Impl; import com.fasterxml.jackson.databind.type.SimpleType; import com.fasterxml.jackson.databind.type.TypeFactory; import com.fasterxml.jackson.databind.type.TypeModifier; import com.fasterxml.jackson.databind.util.ClassUtil; import com.fasterxml.jackson.databind.util.RootNameLookup; import com.fasterxml.jackson.databind.util.StdDateFormat; import com.fasterxml.jackson.databind.util.TokenBuffer; import java.io.Closeable; import java.io.DataInput; import java.io.DataOutput; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; import java.io.Serializable; import java.io.Writer; import java.lang.reflect.Type; import java.net.URL; import java.security.AccessController; import java.security.PrivilegedAction; import java.text.DateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.ServiceLoader; import java.util.Set; import java.util.TimeZone; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicReference; public class ObjectMapper extends ObjectCodec implements Versioned, Serializable { private static final long serialVersionUID = 2L; private static final JavaType JSON_NODE_TYPE = SimpleType.constructUnsafe(JsonNode.class); protected static final AnnotationIntrospector DEFAULT_ANNOTATION_INTROSPECTOR = new JacksonAnnotationIntrospector(); protected static final BaseSettings DEFAULT_BASE; protected final JsonFactory _jsonFactory; protected TypeFactory _typeFactory; protected InjectableValues _injectableValues; protected SubtypeResolver _subtypeResolver; protected final ConfigOverrides _configOverrides; protected SimpleMixInResolver _mixIns; protected SerializationConfig _serializationConfig; protected DefaultSerializerProvider _serializerProvider; protected SerializerFactory _serializerFactory; protected DeserializationConfig _deserializationConfig; protected DefaultDeserializationContext _deserializationContext; protected Set<Object> _registeredModuleTypes; protected final ConcurrentHashMap<JavaType, JsonDeserializer<Object>> _rootDeserializers; public ObjectMapper() { this((JsonFactory)null, (DefaultSerializerProvider)null, (DefaultDeserializationContext)null); } public ObjectMapper(JsonFactory jf) { this(jf, (DefaultSerializerProvider)null, (DefaultDeserializationContext)null); } protected ObjectMapper(ObjectMapper src) { this._rootDeserializers = new ConcurrentHashMap(64, 0.6F, 2); this._jsonFactory = src._jsonFactory.copy(); this._jsonFactory.setCodec(this); this._subtypeResolver = src._subtypeResolver; this._typeFactory = src._typeFactory; this._injectableValues = src._injectableValues; this._configOverrides = src._configOverrides.copy(); this._mixIns = src._mixIns.copy(); RootNameLookup rootNames = new RootNameLookup(); this._serializationConfig = new SerializationConfig(src._serializationConfig, this._mixIns, rootNames, this._configOverrides); this._deserializationConfig = new DeserializationConfig(src._deserializationConfig, this._mixIns, rootNames, this._configOverrides); this._serializerProvider = src._serializerProvider.copy(); this._deserializationContext = src._deserializationContext.copy(); this._serializerFactory = src._serializerFactory; Set<Object> reg = src._registeredModuleTypes; if (reg == null) { this._registeredModuleTypes = null; } else { this._registeredModuleTypes = new LinkedHashSet(reg); } } public ObjectMapper(JsonFactory jf, DefaultSerializerProvider sp, DefaultDeserializationContext dc) { this._rootDeserializers = new ConcurrentHashMap(64, 0.6F, 2); if (jf == null) { this._jsonFactory = new MappingJsonFactory(this); } else { this._jsonFactory = jf; if (jf.getCodec() == null) { this._jsonFactory.setCodec(this); } } this._subtypeResolver = new StdSubtypeResolver(); RootNameLookup rootNames = new RootNameLookup(); this._typeFactory = TypeFactory.defaultInstance(); SimpleMixInResolver mixins = new SimpleMixInResolver((MixInResolver)null); this._mixIns = mixins; BaseSettings base = DEFAULT_BASE.withClassIntrospector(this.defaultClassIntrospector()); this._configOverrides = new ConfigOverrides(); this._serializationConfig = new SerializationConfig(base, this._subtypeResolver, mixins, rootNames, this._configOverrides); this._deserializationConfig = new DeserializationConfig(base, this._subtypeResolver, mixins, rootNames, this._configOverrides); boolean needOrder = this._jsonFactory.requiresPropertyOrdering(); if (needOrder ^ this._serializationConfig.isEnabled(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY)) { this.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, needOrder); } this._serializerProvider = (DefaultSerializerProvider)(sp == null ? new Impl() : sp); this._deserializationContext = (DefaultDeserializationContext)(dc == null ? new com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.Impl(BeanDeserializerFactory.instance) : dc); this._serializerFactory = BeanSerializerFactory.instance; } protected ClassIntrospector defaultClassIntrospector() { return new BasicClassIntrospector(); } public ObjectMapper copy() { this._checkInvalidCopy(ObjectMapper.class); return new ObjectMapper(this); } protected void _checkInvalidCopy(Class<?> exp) { if (this.getClass() != exp) { throw new IllegalStateException("Failed copy(): " + this.getClass().getName() + " (version: " + this.version() + ") does not override copy(); it has to"); } } protected ObjectReader _newReader(DeserializationConfig config) { return new ObjectReader(this, config); } protected ObjectReader _newReader(DeserializationConfig config, JavaType valueType, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues) { return new ObjectReader(this, config, valueType, valueToUpdate, schema, injectableValues); } protected ObjectWriter _newWriter(SerializationConfig config) { return new ObjectWriter(this, config); } protected ObjectWriter _newWriter(SerializationConfig config, FormatSchema schema) { return new ObjectWriter(this, config, schema); } protected ObjectWriter _newWriter(SerializationConfig config, JavaType rootType, PrettyPrinter pp) { return new ObjectWriter(this, config, rootType, pp); } public Version version() { return PackageVersion.VERSION; } public ObjectMapper registerModule(Module module) { if (this.isEnabled(MapperFeature.IGNORE_DUPLICATE_MODULE_REGISTRATIONS)) { Object typeId = module.getTypeId(); if (typeId != null) { if (this._registeredModuleTypes == null) { this._registeredModuleTypes = new LinkedHashSet(); } if (!this._registeredModuleTypes.add(typeId)) { return this; } } } String name = module.getModuleName(); if (name == null) { throw new IllegalArgumentException("Module without defined name"); } else { Version version = module.version(); if (version == null) { throw new IllegalArgumentException("Module without defined version"); } else { module.setupModule(new SetupContext() { public Version getMapperVersion() { return ObjectMapper.this.version(); } public <C extends ObjectCodec> C getOwner() { return ObjectMapper.this; } public TypeFactory getTypeFactory() { return ObjectMapper.this._typeFactory; } public boolean isEnabled(MapperFeature f) { return ObjectMapper.this.isEnabled(f); } public boolean isEnabled(DeserializationFeature f) { return ObjectMapper.this.isEnabled(f); } public boolean isEnabled(SerializationFeature f) { return ObjectMapper.this.isEnabled(f); } public boolean isEnabled(Feature f) { return ObjectMapper.this.isEnabled(f); } public boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) { return ObjectMapper.this.isEnabled(f); } public boolean isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f) { return ObjectMapper.this.isEnabled(f); } public MutableConfigOverride configOverride(Class<?> type) { return ObjectMapper.this.configOverride(type); } public void addDeserializers(Deserializers d) { DeserializerFactory df = ObjectMapper.this._deserializationContext._factory.withAdditionalDeserializers(d); ObjectMapper.this._deserializationContext = ObjectMapper.this._deserializationContext.with(df); } public void addKeyDeserializers(KeyDeserializers d) { DeserializerFactory df = ObjectMapper.this._deserializationContext._factory.withAdditionalKeyDeserializers(d); ObjectMapper.this._deserializationContext = ObjectMapper.this._deserializationContext.with(df); } public void addBeanDeserializerModifier(BeanDeserializerModifier modifier) { DeserializerFactory df = ObjectMapper.this._deserializationContext._factory.withDeserializerModifier(modifier); ObjectMapper.this._deserializationContext = ObjectMapper.this._deserializationContext.with(df); } public void addSerializers(Serializers s) { ObjectMapper.this._serializerFactory = ObjectMapper.this._serializerFactory.withAdditionalSerializers(s); } public void addKeySerializers(Serializers s) { ObjectMapper.this._serializerFactory = ObjectMapper.this._serializerFactory.withAdditionalKeySerializers(s); } public void addBeanSerializerModifier(BeanSerializerModifier modifier) { ObjectMapper.this._serializerFactory = ObjectMapper.this._serializerFactory.withSerializerModifier(modifier); } public void addAbstractTypeResolver(AbstractTypeResolver resolver) { DeserializerFactory df = ObjectMapper.this._deserializationContext._factory.withAbstractTypeResolver(resolver); ObjectMapper.this._deserializationContext = ObjectMapper.this._deserializationContext.with(df); } public void addTypeModifier(TypeModifier modifier) { TypeFactory f = ObjectMapper.this._typeFactory; f = f.withModifier(modifier); ObjectMapper.this.setTypeFactory(f); } public void addValueInstantiators(ValueInstantiators instantiators) { DeserializerFactory df = ObjectMapper.this._deserializationContext._factory.withValueInstantiators(instantiators); ObjectMapper.this._deserializationContext = ObjectMapper.this._deserializationContext.with(df); } public void setClassIntrospector(ClassIntrospector ci) { ObjectMapper.this._deserializationConfig = (DeserializationConfig)ObjectMapper.this._deserializationConfig.with(ci); ObjectMapper.this._serializationConfig = (SerializationConfig)ObjectMapper.this._serializationConfig.with(ci); } public void insertAnnotationIntrospector(AnnotationIntrospector ai) { ObjectMapper.this._deserializationConfig = (DeserializationConfig)ObjectMapper.this._deserializationConfig.withInsertedAnnotationIntrospector(ai); ObjectMapper.this._serializationConfig = (SerializationConfig)ObjectMapper.this._serializationConfig.withInsertedAnnotationIntrospector(ai); } public void appendAnnotationIntrospector(AnnotationIntrospector ai) { ObjectMapper.this._deserializationConfig = (DeserializationConfig)ObjectMapper.this._deserializationConfig.withAppendedAnnotationIntrospector(ai); ObjectMapper.this._serializationConfig = (SerializationConfig)ObjectMapper.this._serializationConfig.withAppendedAnnotationIntrospector(ai); } public void registerSubtypes(Class... subtypes) { ObjectMapper.this.registerSubtypes(subtypes); } public void registerSubtypes(NamedType... subtypes) { ObjectMapper.this.registerSubtypes(subtypes); } public void registerSubtypes(Collection<Class<?>> subtypes) { ObjectMapper.this.registerSubtypes(subtypes); } public void setMixInAnnotations(Class<?> target, Class<?> mixinSource) { ObjectMapper.this.addMixIn(target, mixinSource); } public void addDeserializationProblemHandler(DeserializationProblemHandler handler) { ObjectMapper.this.addHandler(handler); } public void setNamingStrategy(PropertyNamingStrategy naming) { ObjectMapper.this.setPropertyNamingStrategy(naming); } }); return this; } } } public ObjectMapper registerModules(Module... modules) { Module[] var2 = modules; int var3 = modules.length; for(int var4 = 0; var4 < var3; ++var4) { Module module = var2[var4]; this.registerModule(module); } return this; } public ObjectMapper registerModules(Iterable<? extends Module> modules) { Iterator var2 = modules.iterator(); while(var2.hasNext()) { Module module = (Module)var2.next(); this.registerModule(module); } return this; } public static List<Module> findModules() { return findModules((ClassLoader)null); } public static List<Module> findModules(ClassLoader classLoader) { ArrayList<Module> modules = new ArrayList(); ServiceLoader<Module> loader = secureGetServiceLoader(Module.class, classLoader); Iterator var3 = loader.iterator(); while(var3.hasNext()) { Module module = (Module)var3.next(); modules.add(module); } return modules; } private static <T> ServiceLoader<T> secureGetServiceLoader(final Class<T> clazz, final ClassLoader classLoader) { SecurityManager sm = System.getSecurityManager(); if (sm == null) { return classLoader == null ? ServiceLoader.load(clazz) : ServiceLoader.load(clazz, classLoader); } else { return (ServiceLoader)AccessController.doPrivileged(new PrivilegedAction<ServiceLoader<T>>() { public ServiceLoader<T> run() { return classLoader == null ? ServiceLoader.load(clazz) : ServiceLoader.load(clazz, classLoader); } }); } } public ObjectMapper findAndRegisterModules() { return this.registerModules((Iterable)findModules()); } public SerializationConfig getSerializationConfig() { return this._serializationConfig; } public DeserializationConfig getDeserializationConfig() { return this._deserializationConfig; } public DeserializationContext getDeserializationContext() { return this._deserializationContext; } public ObjectMapper setSerializerFactory(SerializerFactory f) { this._serializerFactory = f; return this; } public SerializerFactory getSerializerFactory() { return this._serializerFactory; } public ObjectMapper setSerializerProvider(DefaultSerializerProvider p) { this._serializerProvider = p; return this; } public SerializerProvider getSerializerProvider() { return this._serializerProvider; } public SerializerProvider getSerializerProviderInstance() { return this._serializerProvider(this._serializationConfig); } public ObjectMapper setMixIns(Map<Class<?>, Class<?>> sourceMixins) { this._mixIns.setLocalDefinitions(sourceMixins); return this; } public ObjectMapper addMixIn(Class<?> target, Class<?> mixinSource) { this._mixIns.addLocalDefinition(target, mixinSource); return this; } public ObjectMapper setMixInResolver(MixInResolver resolver) { SimpleMixInResolver r = this._mixIns.withOverrides(resolver); if (r != this._mixIns) { this._mixIns = r; this._deserializationConfig = new DeserializationConfig(this._deserializationConfig, r); this._serializationConfig = new SerializationConfig(this._serializationConfig, r); } return this; } public Class<?> findMixInClassFor(Class<?> cls) { return this._mixIns.findMixInClassFor(cls); } public int mixInCount() { return this._mixIns.localSize(); } /** @deprecated */ @Deprecated public void setMixInAnnotations(Map<Class<?>, Class<?>> sourceMixins) { this.setMixIns(sourceMixins); } /** @deprecated */ @Deprecated public final void addMixInAnnotations(Class<?> target, Class<?> mixinSource) { this.addMixIn(target, mixinSource); } public VisibilityChecker<?> getVisibilityChecker() { return this._serializationConfig.getDefaultVisibilityChecker(); } public ObjectMapper setVisibility(VisibilityChecker<?> vc) { this._configOverrides.setDefaultVisibility(vc); return this; } public ObjectMapper setVisibility(PropertyAccessor forMethod, Visibility visibility) { VisibilityChecker<?> vc = this._configOverrides.getDefaultVisibility(); vc = vc.withVisibility(forMethod, visibility); this._configOverrides.setDefaultVisibility(vc); return this; } public SubtypeResolver getSubtypeResolver() { return this._subtypeResolver; } public ObjectMapper setSubtypeResolver(SubtypeResolver str) { this._subtypeResolver = str; this._deserializationConfig = this._deserializationConfig.with(str); this._serializationConfig = this._serializationConfig.with(str); return this; } public ObjectMapper setAnnotationIntrospector(AnnotationIntrospector ai) { this._serializationConfig = (SerializationConfig)this._serializationConfig.with(ai); this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(ai); return this; } public ObjectMapper setAnnotationIntrospectors(AnnotationIntrospector serializerAI, AnnotationIntrospector deserializerAI) { this._serializationConfig = (SerializationConfig)this._serializationConfig.with(serializerAI); this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(deserializerAI); return this; } public ObjectMapper setPropertyNamingStrategy(PropertyNamingStrategy s) { this._serializationConfig = (SerializationConfig)this._serializationConfig.with(s); this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(s); return this; } public PropertyNamingStrategy getPropertyNamingStrategy() { return this._serializationConfig.getPropertyNamingStrategy(); } public ObjectMapper setDefaultPrettyPrinter(PrettyPrinter pp) { this._serializationConfig = this._serializationConfig.withDefaultPrettyPrinter(pp); return this; } /** @deprecated */ @Deprecated public void setVisibilityChecker(VisibilityChecker<?> vc) { this.setVisibility(vc); } public ObjectMapper setSerializationInclusion(Include incl) { this.setPropertyInclusion(Value.construct(incl, incl)); return this; } /** @deprecated */ @Deprecated public ObjectMapper setPropertyInclusion(Value incl) { return this.setDefaultPropertyInclusion(incl); } public ObjectMapper setDefaultPropertyInclusion(Value incl) { this._configOverrides.setDefaultInclusion(incl); return this; } public ObjectMapper setDefaultPropertyInclusion(Include incl) { this._configOverrides.setDefaultInclusion(Value.construct(incl, incl)); return this; } public ObjectMapper setDefaultSetterInfo(com.fasterxml.jackson.annotation.JsonSetter.Value v) { this._configOverrides.setDefaultSetterInfo(v); return this; } public ObjectMapper setDefaultVisibility(com.fasterxml.jackson.annotation.JsonAutoDetect.Value vis) { this._configOverrides.setDefaultVisibility(Std.construct(vis)); return this; } public ObjectMapper setDefaultMergeable(Boolean b) { this._configOverrides.setDefaultMergeable(b); return this; } public ObjectMapper enableDefaultTyping() { return this.enableDefaultTyping(ObjectMapper.DefaultTyping.OBJECT_AND_NON_CONCRETE); } public ObjectMapper enableDefaultTyping(ObjectMapper.DefaultTyping dti) { return this.enableDefaultTyping(dti, As.WRAPPER_ARRAY); } public ObjectMapper enableDefaultTyping(ObjectMapper.DefaultTyping applicability, As includeAs) { if (includeAs == As.EXTERNAL_PROPERTY) { throw new IllegalArgumentException("Cannot use includeAs of " + includeAs); } else { TypeResolverBuilder<?> typer = new ObjectMapper.DefaultTypeResolverBuilder(applicability); TypeResolverBuilder<?> typer = typer.init(Id.CLASS, (TypeIdResolver)null); typer = typer.inclusion(includeAs); return this.setDefaultTyping(typer); } } public ObjectMapper enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping applicability, String propertyName) { TypeResolverBuilder<?> typer = new ObjectMapper.DefaultTypeResolverBuilder(applicability); TypeResolverBuilder<?> typer = typer.init(Id.CLASS, (TypeIdResolver)null); typer = typer.inclusion(As.PROPERTY); typer = typer.typeProperty(propertyName); return this.setDefaultTyping(typer); } public ObjectMapper disableDefaultTyping() { return this.setDefaultTyping((TypeResolverBuilder)null); } public ObjectMapper setDefaultTyping(TypeResolverBuilder<?> typer) { this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(typer); this._serializationConfig = (SerializationConfig)this._serializationConfig.with(typer); return this; } public void registerSubtypes(Class... classes) { this.getSubtypeResolver().registerSubtypes(classes); } public void registerSubtypes(NamedType... types) { this.getSubtypeResolver().registerSubtypes(types); } public void registerSubtypes(Collection<Class<?>> subtypes) { this.getSubtypeResolver().registerSubtypes(subtypes); } public MutableConfigOverride configOverride(Class<?> type) { return this._configOverrides.findOrCreateOverride(type); } public TypeFactory getTypeFactory() { return this._typeFactory; } public ObjectMapper setTypeFactory(TypeFactory f) { this._typeFactory = f; this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(f); this._serializationConfig = (SerializationConfig)this._serializationConfig.with(f); return this; } public JavaType constructType(Type t) { return this._typeFactory.constructType(t); } public JsonNodeFactory getNodeFactory() { return this._deserializationConfig.getNodeFactory(); } public ObjectMapper setNodeFactory(JsonNodeFactory f) { this._deserializationConfig = this._deserializationConfig.with(f); return this; } public ObjectMapper addHandler(DeserializationProblemHandler h) { this._deserializationConfig = this._deserializationConfig.withHandler(h); return this; } public ObjectMapper clearProblemHandlers() { this._deserializationConfig = this._deserializationConfig.withNoProblemHandlers(); return this; } public ObjectMapper setConfig(DeserializationConfig config) { this._deserializationConfig = config; return this; } /** @deprecated */ @Deprecated public void setFilters(FilterProvider filterProvider) { this._serializationConfig = this._serializationConfig.withFilters(filterProvider); } public ObjectMapper setFilterProvider(FilterProvider filterProvider) { this._serializationConfig = this._serializationConfig.withFilters(filterProvider); return this; } public ObjectMapper setBase64Variant(Base64Variant v) { this._serializationConfig = (SerializationConfig)this._serializationConfig.with(v); this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(v); return this; } public ObjectMapper setConfig(SerializationConfig config) { this._serializationConfig = config; return this; } public JsonFactory getFactory() { return this._jsonFactory; } /** @deprecated */ @Deprecated public JsonFactory getJsonFactory() { return this.getFactory(); } public ObjectMapper setDateFormat(DateFormat dateFormat) { this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(dateFormat); this._serializationConfig = this._serializationConfig.with(dateFormat); return this; } public DateFormat getDateFormat() { return this._serializationConfig.getDateFormat(); } public Object setHandlerInstantiator(HandlerInstantiator hi) { this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(hi); this._serializationConfig = (SerializationConfig)this._serializationConfig.with(hi); return this; } public ObjectMapper setInjectableValues(InjectableValues injectableValues) { this._injectableValues = injectableValues; return this; } public InjectableValues getInjectableValues() { return this._injectableValues; } public ObjectMapper setLocale(Locale l) { this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(l); this._serializationConfig = (SerializationConfig)this._serializationConfig.with(l); return this; } public ObjectMapper setTimeZone(TimeZone tz) { this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(tz); this._serializationConfig = (SerializationConfig)this._serializationConfig.with(tz); return this; } public boolean isEnabled(MapperFeature f) { return this._serializationConfig.isEnabled(f); } public ObjectMapper configure(MapperFeature f, boolean state) { this._serializationConfig = state ? (SerializationConfig)this._serializationConfig.with(new MapperFeature[]{f}) : (SerializationConfig)this._serializationConfig.without(new MapperFeature[]{f}); this._deserializationConfig = state ? (DeserializationConfig)this._deserializationConfig.with(new MapperFeature[]{f}) : (DeserializationConfig)this._deserializationConfig.without(new MapperFeature[]{f}); return this; } public ObjectMapper enable(MapperFeature... f) { this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(f); this._serializationConfig = (SerializationConfig)this._serializationConfig.with(f); return this; } public ObjectMapper disable(MapperFeature... f) { this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.without(f); this._serializationConfig = (SerializationConfig)this._serializationConfig.without(f); return this; } public boolean isEnabled(SerializationFeature f) { return this._serializationConfig.isEnabled(f); } public ObjectMapper configure(SerializationFeature f, boolean state) { this._serializationConfig = state ? this._serializationConfig.with(f) : this._serializationConfig.without(f); return this; } public ObjectMapper enable(SerializationFeature f) { this._serializationConfig = this._serializationConfig.with(f); return this; } public ObjectMapper enable(SerializationFeature first, SerializationFeature... f) { this._serializationConfig = this._serializationConfig.with(first, f); return this; } public ObjectMapper disable(SerializationFeature f) { this._serializationConfig = this._serializationConfig.without(f); return this; } public ObjectMapper disable(SerializationFeature first, SerializationFeature... f) { this._serializationConfig = this._serializationConfig.without(first, f); return this; } public boolean isEnabled(DeserializationFeature f) { return this._deserializationConfig.isEnabled(f); } public ObjectMapper configure(DeserializationFeature f, boolean state) { this._deserializationConfig = state ? this._deserializationConfig.with(f) : this._deserializationConfig.without(f); return this; } public ObjectMapper enable(DeserializationFeature feature) { this._deserializationConfig = this._deserializationConfig.with(feature); return this; } public ObjectMapper enable(DeserializationFeature first, DeserializationFeature... f) { this._deserializationConfig = this._deserializationConfig.with(first, f); return this; } public ObjectMapper disable(DeserializationFeature feature) { this._deserializationConfig = this._deserializationConfig.without(feature); return this; } public ObjectMapper disable(DeserializationFeature first, DeserializationFeature... f) { this._deserializationConfig = this._deserializationConfig.without(first, f); return this; } public boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) { return this._deserializationConfig.isEnabled(f, this._jsonFactory); } public ObjectMapper configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) { this._jsonFactory.configure(f, state); return this; } public ObjectMapper enable(com.fasterxml.jackson.core.JsonParser.Feature... features) { com.fasterxml.jackson.core.JsonParser.Feature[] var2 = features; int var3 = features.length; for(int var4 = 0; var4 < var3; ++var4) { com.fasterxml.jackson.core.JsonParser.Feature f = var2[var4]; this._jsonFactory.enable(f); } return this; } public ObjectMapper disable(com.fasterxml.jackson.core.JsonParser.Feature... features) { com.fasterxml.jackson.core.JsonParser.Feature[] var2 = features; int var3 = features.length; for(int var4 = 0; var4 < var3; ++var4) { com.fasterxml.jackson.core.JsonParser.Feature f = var2[var4]; this._jsonFactory.disable(f); } return this; } public boolean isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f) { return this._serializationConfig.isEnabled(f, this._jsonFactory); } public ObjectMapper configure(com.fasterxml.jackson.core.JsonGenerator.Feature f, boolean state) { this._jsonFactory.configure(f, state); return this; } public ObjectMapper enable(com.fasterxml.jackson.core.JsonGenerator.Feature... features) { com.fasterxml.jackson.core.JsonGenerator.Feature[] var2 = features; int var3 = features.length; for(int var4 = 0; var4 < var3; ++var4) { com.fasterxml.jackson.core.JsonGenerator.Feature f = var2[var4]; this._jsonFactory.enable(f); } return this; } public ObjectMapper disable(com.fasterxml.jackson.core.JsonGenerator.Feature... features) { com.fasterxml.jackson.core.JsonGenerator.Feature[] var2 = features; int var3 = features.length; for(int var4 = 0; var4 < var3; ++var4) { com.fasterxml.jackson.core.JsonGenerator.Feature f = var2[var4]; this._jsonFactory.disable(f); } return this; } public boolean isEnabled(Feature f) { return this._jsonFactory.isEnabled(f); } public <T> T readValue(JsonParser p, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return this._readValue(this.getDeserializationConfig(), p, this._typeFactory.constructType(valueType)); } public <T> T readValue(JsonParser p, TypeReference<?> valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return this._readValue(this.getDeserializationConfig(), p, this._typeFactory.constructType(valueTypeRef)); } public final <T> T readValue(JsonParser p, ResolvedType valueType) throws IOException, JsonParseException, JsonMappingException { return this._readValue(this.getDeserializationConfig(), p, (JavaType)valueType); } public <T> T readValue(JsonParser p, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return this._readValue(this.getDeserializationConfig(), p, valueType); } public <T extends TreeNode> T readTree(JsonParser p) throws IOException, JsonProcessingException { DeserializationConfig cfg = this.getDeserializationConfig(); JsonToken t = p.getCurrentToken(); if (t == null) { t = p.nextToken(); if (t == null) { return null; } } JsonNode n = (JsonNode)this._readValue(cfg, p, JSON_NODE_TYPE); if (n == null) { n = this.getNodeFactory().nullNode(); } return (TreeNode)n; } public <T> MappingIterator<T> readValues(JsonParser p, ResolvedType valueType) throws IOException, JsonProcessingException { return this.readValues(p, (JavaType)valueType); } public <T> MappingIterator<T> readValues(JsonParser p, JavaType valueType) throws IOException, JsonProcessingException { DeserializationConfig config = this.getDeserializationConfig(); DeserializationContext ctxt = this.createDeserializationContext(p, config); JsonDeserializer<?> deser = this._findRootDeserializer(ctxt, valueType); return new MappingIterator(valueType, p, ctxt, deser, false, (Object)null); } public <T> MappingIterator<T> readValues(JsonParser p, Class<T> valueType) throws IOException, JsonProcessingException { return this.readValues(p, this._typeFactory.constructType(valueType)); } public <T> MappingIterator<T> readValues(JsonParser p, TypeReference<?> valueTypeRef) throws IOException, JsonProcessingException { return this.readValues(p, this._typeFactory.constructType(valueTypeRef)); } public JsonNode readTree(InputStream in) throws IOException { return this._readTreeAndClose(this._jsonFactory.createParser(in)); } public JsonNode readTree(Reader r) throws IOException { return this._readTreeAndClose(this._jsonFactory.createParser(r)); } public JsonNode readTree(String content) throws IOException { return this._readTreeAndClose(this._jsonFactory.createParser(content)); } public JsonNode readTree(byte[] content) throws IOException { return this._readTreeAndClose(this._jsonFactory.createParser(content)); } public JsonNode readTree(File file) throws IOException, JsonProcessingException { return this._readTreeAndClose(this._jsonFactory.createParser(file)); } public JsonNode readTree(URL source) throws IOException { return this._readTreeAndClose(this._jsonFactory.createParser(source)); } public void writeValue(JsonGenerator g, Object value) throws IOException, JsonGenerationException, JsonMappingException { SerializationConfig config = this.getSerializationConfig(); if (config.isEnabled(SerializationFeature.INDENT_OUTPUT) && g.getPrettyPrinter() == null) { g.setPrettyPrinter(config.constructDefaultPrettyPrinter()); } if (config.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && value instanceof Closeable) { this._writeCloseableValue(g, value, config); } else { this._serializerProvider(config).serializeValue(g, value); if (config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { g.flush(); } } } public void writeTree(JsonGenerator jgen, TreeNode rootNode) throws IOException, JsonProcessingException { SerializationConfig config = this.getSerializationConfig(); this._serializerProvider(config).serializeValue(jgen, rootNode); if (config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { jgen.flush(); } } public void writeTree(JsonGenerator jgen, JsonNode rootNode) throws IOException, JsonProcessingException { SerializationConfig config = this.getSerializationConfig(); this._serializerProvider(config).serializeValue(jgen, rootNode); if (config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { jgen.flush(); } } public ObjectNode createObjectNode() { return this._deserializationConfig.getNodeFactory().objectNode(); } public ArrayNode createArrayNode() { return this._deserializationConfig.getNodeFactory().arrayNode(); } public JsonParser treeAsTokens(TreeNode n) { return new TreeTraversingParser((JsonNode)n, this); } public <T> T treeToValue(TreeNode n, Class<T> valueType) throws JsonProcessingException { try { if (valueType != Object.class && valueType.isAssignableFrom(n.getClass())) { return n; } else { if (n.asToken() == JsonToken.VALUE_EMBEDDED_OBJECT && n instanceof POJONode) { Object ob = ((POJONode)n).getPojo(); if (ob == null || valueType.isInstance(ob)) { return ob; } } return this.readValue(this.treeAsTokens(n), valueType); } } catch (JsonProcessingException var4) { throw var4; } catch (IOException var5) { throw new IllegalArgumentException(var5.getMessage(), var5); } } public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) { return null; } else { TokenBuffer buf = new TokenBuffer(this, false); if (this.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) { buf = buf.forceUseOfBigDecimal(true); } try { this.writeValue((JsonGenerator)buf, fromValue); JsonParser p = buf.asParser(); JsonNode result = (JsonNode)this.readTree(p); p.close(); return result; } catch (IOException var5) { throw new IllegalArgumentException(var5.getMessage(), var5); } } } public boolean canSerialize(Class<?> type) { return this._serializerProvider(this.getSerializationConfig()).hasSerializerFor(type, (AtomicReference)null); } public boolean canSerialize(Class<?> type, AtomicReference<Throwable> cause) { return this._serializerProvider(this.getSerializationConfig()).hasSerializerFor(type, cause); } public boolean canDeserialize(JavaType type) { return this.createDeserializationContext((JsonParser)null, this.getDeserializationConfig()).hasValueDeserializerFor(type, (AtomicReference)null); } public boolean canDeserialize(JavaType type, AtomicReference<Throwable> cause) { return this.createDeserializationContext((JsonParser)null, this.getDeserializationConfig()).hasValueDeserializerFor(type, cause); } public <T> T readValue(File src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueType)); } public <T> T readValue(File src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueTypeRef)); } public <T> T readValue(File src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src), valueType); } public <T> T readValue(URL src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueType)); } public <T> T readValue(URL src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueTypeRef)); } public <T> T readValue(URL src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src), valueType); } public <T> T readValue(String content, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(content), this._typeFactory.constructType(valueType)); } public <T> T readValue(String content, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(content), this._typeFactory.constructType(valueTypeRef)); } public <T> T readValue(String content, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(content), valueType); } public <T> T readValue(Reader src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueType)); } public <T> T readValue(Reader src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueTypeRef)); } public <T> T readValue(Reader src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src), valueType); } public <T> T readValue(InputStream src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueType)); } public <T> T readValue(InputStream src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueTypeRef)); } public <T> T readValue(InputStream src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src), valueType); } public <T> T readValue(byte[] src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueType)); } public <T> T readValue(byte[] src, int offset, int len, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src, offset, len), this._typeFactory.constructType(valueType)); } public <T> T readValue(byte[] src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueTypeRef)); } public <T> T readValue(byte[] src, int offset, int len, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src, offset, len), this._typeFactory.constructType(valueTypeRef)); } public <T> T readValue(byte[] src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src), valueType); } public <T> T readValue(byte[] src, int offset, int len, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return this._readMapAndClose(this._jsonFactory.createParser(src, offset, len), valueType); } public <T> T readValue(DataInput src, Class<T> valueType) throws IOException { return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueType)); } public <T> T readValue(DataInput src, JavaType valueType) throws IOException { return this._readMapAndClose(this._jsonFactory.createParser(src), valueType); } public void writeValue(File resultFile, Object value) throws IOException, JsonGenerationException, JsonMappingException { this._configAndWriteValue(this._jsonFactory.createGenerator(resultFile, JsonEncoding.UTF8), value); } public void writeValue(OutputStream out, Object value) throws IOException, JsonGenerationException, JsonMappingException { this._configAndWriteValue(this._jsonFactory.createGenerator(out, JsonEncoding.UTF8), value); } public void writeValue(DataOutput out, Object value) throws IOException { this._configAndWriteValue(this._jsonFactory.createGenerator(out, JsonEncoding.UTF8), value); } public void writeValue(Writer w, Object value) throws IOException, JsonGenerationException, JsonMappingException { this._configAndWriteValue(this._jsonFactory.createGenerator(w), value); } public String writeValueAsString(Object value) throws JsonProcessingException { SegmentedStringWriter sw = new SegmentedStringWriter(this._jsonFactory._getBufferRecycler()); try { this._configAndWriteValue(this._jsonFactory.createGenerator(sw), value); } catch (JsonProcessingException var4) { throw var4; } catch (IOException var5) { throw JsonMappingException.fromUnexpectedIOE(var5); } return sw.getAndClear(); } public byte[] writeValueAsBytes(Object value) throws JsonProcessingException { ByteArrayBuilder bb = new ByteArrayBuilder(this._jsonFactory._getBufferRecycler()); try { this._configAndWriteValue(this._jsonFactory.createGenerator(bb, JsonEncoding.UTF8), value); } catch (JsonProcessingException var4) { throw var4; } catch (IOException var5) { throw JsonMappingException.fromUnexpectedIOE(var5); } byte[] result = bb.toByteArray(); bb.release(); return result; } public ObjectWriter writer() { return this._newWriter(this.getSerializationConfig()); } public ObjectWriter writer(SerializationFeature feature) { return this._newWriter(this.getSerializationConfig().with(feature)); } public ObjectWriter writer(SerializationFeature first, SerializationFeature... other) { return this._newWriter(this.getSerializationConfig().with(first, other)); } public ObjectWriter writer(DateFormat df) { return this._newWriter(this.getSerializationConfig().with(df)); } public ObjectWriter writerWithView(Class<?> serializationView) { return this._newWriter(this.getSerializationConfig().withView(serializationView)); } public ObjectWriter writerFor(Class<?> rootType) { return this._newWriter(this.getSerializationConfig(), rootType == null ? null : this._typeFactory.constructType(rootType), (PrettyPrinter)null); } public ObjectWriter writerFor(TypeReference<?> rootType) { return this._newWriter(this.getSerializationConfig(), rootType == null ? null : this._typeFactory.constructType(rootType), (PrettyPrinter)null); } public ObjectWriter writerFor(JavaType rootType) { return this._newWriter(this.getSerializationConfig(), rootType, (PrettyPrinter)null); } public ObjectWriter writer(PrettyPrinter pp) { if (pp == null) { pp = ObjectWriter.NULL_PRETTY_PRINTER; } return this._newWriter(this.getSerializationConfig(), (JavaType)null, pp); } public ObjectWriter writerWithDefaultPrettyPrinter() { SerializationConfig config = this.getSerializationConfig(); return this._newWriter(config, (JavaType)null, config.getDefaultPrettyPrinter()); } public ObjectWriter writer(FilterProvider filterProvider) { return this._newWriter(this.getSerializationConfig().withFilters(filterProvider)); } public ObjectWriter writer(FormatSchema schema) { this._verifySchemaType(schema); return this._newWriter(this.getSerializationConfig(), schema); } public ObjectWriter writer(Base64Variant defaultBase64) { return this._newWriter((SerializationConfig)this.getSerializationConfig().with(defaultBase64)); } public ObjectWriter writer(CharacterEscapes escapes) { return this._newWriter(this.getSerializationConfig()).with(escapes); } public ObjectWriter writer(ContextAttributes attrs) { return this._newWriter(this.getSerializationConfig().with(attrs)); } /** @deprecated */ @Deprecated public ObjectWriter writerWithType(Class<?> rootType) { return this._newWriter(this.getSerializationConfig(), rootType == null ? null : this._typeFactory.constructType(rootType), (PrettyPrinter)null); } /** @deprecated */ @Deprecated public ObjectWriter writerWithType(TypeReference<?> rootType) { return this._newWriter(this.getSerializationConfig(), rootType == null ? null : this._typeFactory.constructType(rootType), (PrettyPrinter)null); } /** @deprecated */ @Deprecated public ObjectWriter writerWithType(JavaType rootType) { return this._newWriter(this.getSerializationConfig(), rootType, (PrettyPrinter)null); } public ObjectReader reader() { return this._newReader(this.getDeserializationConfig()).with(this._injectableValues); } public ObjectReader reader(DeserializationFeature feature) { return this._newReader(this.getDeserializationConfig().with(feature)); } public ObjectReader reader(DeserializationFeature first, DeserializationFeature... other) { return this._newReader(this.getDeserializationConfig().with(first, other)); } public ObjectReader readerForUpdating(Object valueToUpdate) { JavaType t = this._typeFactory.constructType(valueToUpdate.getClass()); return this._newReader(this.getDeserializationConfig(), t, valueToUpdate, (FormatSchema)null, this._injectableValues); } public ObjectReader readerFor(JavaType type) { return this._newReader(this.getDeserializationConfig(), type, (Object)null, (FormatSchema)null, this._injectableValues); } public ObjectReader readerFor(Class<?> type) { return this._newReader(this.getDeserializationConfig(), this._typeFactory.constructType(type), (Object)null, (FormatSchema)null, this._injectableValues); } public ObjectReader readerFor(TypeReference<?> type) { return this._newReader(this.getDeserializationConfig(), this._typeFactory.constructType(type), (Object)null, (FormatSchema)null, this._injectableValues); } public ObjectReader reader(JsonNodeFactory f) { return this._newReader(this.getDeserializationConfig()).with(f); } public ObjectReader reader(FormatSchema schema) { this._verifySchemaType(schema); return this._newReader(this.getDeserializationConfig(), (JavaType)null, (Object)null, schema, this._injectableValues); } public ObjectReader reader(InjectableValues injectableValues) { return this._newReader(this.getDeserializationConfig(), (JavaType)null, (Object)null, (FormatSchema)null, injectableValues); } public ObjectReader readerWithView(Class<?> view) { return this._newReader(this.getDeserializationConfig().withView(view)); } public ObjectReader reader(Base64Variant defaultBase64) { return this._newReader((DeserializationConfig)this.getDeserializationConfig().with(defaultBase64)); } public ObjectReader reader(ContextAttributes attrs) { return this._newReader(this.getDeserializationConfig().with(attrs)); } /** @deprecated */ @Deprecated public ObjectReader reader(JavaType type) { return this._newReader(this.getDeserializationConfig(), type, (Object)null, (FormatSchema)null, this._injectableValues); } /** @deprecated */ @Deprecated public ObjectReader reader(Class<?> type) { return this._newReader(this.getDeserializationConfig(), this._typeFactory.constructType(type), (Object)null, (FormatSchema)null, this._injectableValues); } /** @deprecated */ @Deprecated public ObjectReader reader(TypeReference<?> type) { return this._newReader(this.getDeserializationConfig(), this._typeFactory.constructType(type), (Object)null, (FormatSchema)null, this._injectableValues); } public <T> T convertValue(Object fromValue, Class<T> toValueType) throws IllegalArgumentException { return this._convert(fromValue, this._typeFactory.constructType(toValueType)); } public <T> T convertValue(Object fromValue, TypeReference<?> toValueTypeRef) throws IllegalArgumentException { return this._convert(fromValue, this._typeFactory.constructType(toValueTypeRef)); } public <T> T convertValue(Object fromValue, JavaType toValueType) throws IllegalArgumentException { return this._convert(fromValue, toValueType); } protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { if (fromValue != null) { Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } } TokenBuffer buf = new TokenBuffer(this, false); if (this.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) { buf = buf.forceUseOfBigDecimal(true); } try { SerializationConfig config = this.getSerializationConfig().without(SerializationFeature.WRAP_ROOT_VALUE); this._serializerProvider(config).serializeValue(buf, fromValue); JsonParser p = buf.asParser(); DeserializationConfig deserConfig = this.getDeserializationConfig(); JsonToken t = this._initForReading(p, toValueType); Object result; DefaultDeserializationContext ctxt; if (t == JsonToken.VALUE_NULL) { ctxt = this.createDeserializationContext(p, deserConfig); result = this._findRootDeserializer(ctxt, toValueType).getNullValue(ctxt); } else if (t != JsonToken.END_ARRAY && t != JsonToken.END_OBJECT) { ctxt = this.createDeserializationContext(p, deserConfig); JsonDeserializer<Object> deser = this._findRootDeserializer(ctxt, toValueType); result = deser.deserialize(p, ctxt); } else { result = null; } p.close(); return result; } catch (IOException var11) { throw new IllegalArgumentException(var11.getMessage(), var11); } } public <T> T updateValue(T valueToUpdate, Object overrides) throws JsonMappingException { T result = valueToUpdate; if (valueToUpdate != null && overrides != null) { TokenBuffer buf = new TokenBuffer(this, false); if (this.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) { buf = buf.forceUseOfBigDecimal(true); } try { SerializationConfig config = this.getSerializationConfig().without(SerializationFeature.WRAP_ROOT_VALUE); this._serializerProvider(config).serializeValue(buf, overrides); JsonParser p = buf.asParser(); result = this.readerForUpdating(valueToUpdate).readValue(p); p.close(); } catch (IOException var7) { if (var7 instanceof JsonMappingException) { throw (JsonMappingException)var7; } throw JsonMappingException.fromUnexpectedIOE(var7); } } return result; } /** @deprecated */ @Deprecated public JsonSchema generateJsonSchema(Class<?> t) throws JsonMappingException { return this._serializerProvider(this.getSerializationConfig()).generateJsonSchema(t); } public void acceptJsonFormatVisitor(Class<?> type, JsonFormatVisitorWrapper visitor) throws JsonMappingException { this.acceptJsonFormatVisitor(this._typeFactory.constructType(type), visitor); } public void acceptJsonFormatVisitor(JavaType type, JsonFormatVisitorWrapper visitor) throws JsonMappingException { if (type == null) { throw new IllegalArgumentException("type must be provided"); } else { this._serializerProvider(this.getSerializationConfig()).acceptJsonFormatVisitor(type, visitor); } } protected DefaultSerializerProvider _serializerProvider(SerializationConfig config) { return this._serializerProvider.createInstance(config, this._serializerFactory); } protected final void _configAndWriteValue(JsonGenerator g, Object value) throws IOException { SerializationConfig cfg = this.getSerializationConfig(); cfg.initialize(g); if (cfg.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && value instanceof Closeable) { this._configAndWriteCloseable(g, value, cfg); } else { try { this._serializerProvider(cfg).serializeValue(g, value); } catch (Exception var5) { ClassUtil.closeOnFailAndThrowAsIOE(g, var5); return; } g.close(); } } private final void _configAndWriteCloseable(JsonGenerator g, Object value, SerializationConfig cfg) throws IOException { Closeable toClose = (Closeable)value; try { this._serializerProvider(cfg).serializeValue(g, value); Closeable tmpToClose = toClose; toClose = null; tmpToClose.close(); } catch (Exception var6) { ClassUtil.closeOnFailAndThrowAsIOE(g, toClose, var6); return; } g.close(); } private final void _writeCloseableValue(JsonGenerator g, Object value, SerializationConfig cfg) throws IOException { Closeable toClose = (Closeable)value; try { this._serializerProvider(cfg).serializeValue(g, value); if (cfg.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { g.flush(); } } catch (Exception var6) { ClassUtil.closeOnFailAndThrowAsIOE((JsonGenerator)null, toClose, var6); return; } toClose.close(); } protected Object _readValue(DeserializationConfig cfg, JsonParser p, JavaType valueType) throws IOException { JsonToken t = this._initForReading(p, valueType); DeserializationContext ctxt = this.createDeserializationContext(p, cfg); Object result; if (t == JsonToken.VALUE_NULL) { result = this._findRootDeserializer(ctxt, valueType).getNullValue(ctxt); } else if (t != JsonToken.END_ARRAY && t != JsonToken.END_OBJECT) { JsonDeserializer<Object> deser = this._findRootDeserializer(ctxt, valueType); if (cfg.useRootWrapping()) { result = this._unwrapAndDeserialize(p, ctxt, cfg, valueType, deser); } else { result = deser.deserialize(p, ctxt); } } else { result = null; } p.clearCurrentToken(); if (cfg.isEnabled(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)) { this._verifyNoTrailingTokens(p, ctxt, valueType); } return result; } protected Object _readMapAndClose(JsonParser p0, JavaType valueType) throws IOException { JsonParser p = p0; Throwable var4 = null; Object var20; try { JsonToken t = this._initForReading(p, valueType); DeserializationConfig cfg = this.getDeserializationConfig(); DeserializationContext ctxt = this.createDeserializationContext(p, cfg); Object result; if (t == JsonToken.VALUE_NULL) { result = this._findRootDeserializer(ctxt, valueType).getNullValue(ctxt); } else if (t != JsonToken.END_ARRAY && t != JsonToken.END_OBJECT) { JsonDeserializer<Object> deser = this._findRootDeserializer(ctxt, valueType); if (cfg.useRootWrapping()) { result = this._unwrapAndDeserialize(p, ctxt, cfg, valueType, deser); } else { result = deser.deserialize(p, ctxt); } ctxt.checkUnresolvedObjectId(); } else { result = null; } if (cfg.isEnabled(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)) { this._verifyNoTrailingTokens(p, ctxt, valueType); } var20 = result; } catch (Throwable var18) { var4 = var18; throw var18; } finally { if (p0 != null) { if (var4 != null) { try { p.close(); } catch (Throwable var17) { var4.addSuppressed(var17); } } else { p0.close(); } } } return var20; } protected JsonNode _readTreeAndClose(JsonParser p0) throws IOException { JsonParser p = p0; Throwable var3 = null; NullNode var7; try { JavaType valueType = JSON_NODE_TYPE; DeserializationConfig cfg = this.getDeserializationConfig(); cfg.initialize(p); JsonToken t = p.getCurrentToken(); if (t == null) { t = p.nextToken(); if (t == null) { var7 = null; return var7; } } if (t != JsonToken.VALUE_NULL) { DeserializationContext ctxt = this.createDeserializationContext(p, cfg); JsonDeserializer<Object> deser = this._findRootDeserializer(ctxt, valueType); Object result; if (cfg.useRootWrapping()) { result = this._unwrapAndDeserialize(p, ctxt, cfg, valueType, deser); } else { result = deser.deserialize(p, ctxt); if (cfg.isEnabled(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)) { this._verifyNoTrailingTokens(p, ctxt, valueType); } } JsonNode var10 = (JsonNode)result; return var10; } var7 = cfg.getNodeFactory().nullNode(); } catch (Throwable var21) { var3 = var21; throw var21; } finally { if (p0 != null) { if (var3 != null) { try { p.close(); } catch (Throwable var20) { var3.addSuppressed(var20); } } else { p0.close(); } } } return var7; } protected Object _unwrapAndDeserialize(JsonParser p, DeserializationContext ctxt, DeserializationConfig config, JavaType rootType, JsonDeserializer<Object> deser) throws IOException { PropertyName expRootName = config.findRootName(rootType); String expSimpleName = expRootName.getSimpleName(); if (p.getCurrentToken() != JsonToken.START_OBJECT) { ctxt.reportWrongTokenException(rootType, JsonToken.START_OBJECT, "Current token not START_OBJECT (needed to unwrap root name '%s'), but %s", new Object[]{expSimpleName, p.getCurrentToken()}); } if (p.nextToken() != JsonToken.FIELD_NAME) { ctxt.reportWrongTokenException(rootType, JsonToken.FIELD_NAME, "Current token not FIELD_NAME (to contain expected root name '%s'), but %s", new Object[]{expSimpleName, p.getCurrentToken()}); } String actualName = p.getCurrentName(); if (!expSimpleName.equals(actualName)) { ctxt.reportInputMismatch(rootType, "Root name '%s' does not match expected ('%s') for type %s", new Object[]{actualName, expSimpleName, rootType}); } p.nextToken(); Object result = deser.deserialize(p, ctxt); if (p.nextToken() != JsonToken.END_OBJECT) { ctxt.reportWrongTokenException(rootType, JsonToken.END_OBJECT, "Current token not END_OBJECT (to match wrapper object with root name '%s'), but %s", new Object[]{expSimpleName, p.getCurrentToken()}); } if (config.isEnabled(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)) { this._verifyNoTrailingTokens(p, ctxt, rootType); } return result; } protected DefaultDeserializationContext createDeserializationContext(JsonParser p, DeserializationConfig cfg) { return this._deserializationContext.createInstance(cfg, p, this._injectableValues); } protected JsonToken _initForReading(JsonParser p, JavaType targetType) throws IOException { this._deserializationConfig.initialize(p); JsonToken t = p.getCurrentToken(); if (t == null) { t = p.nextToken(); if (t == null) { throw MismatchedInputException.from(p, targetType, "No content to map due to end-of-input"); } } return t; } /** @deprecated */ @Deprecated protected JsonToken _initForReading(JsonParser p) throws IOException { return this._initForReading(p, (JavaType)null); } protected final void _verifyNoTrailingTokens(JsonParser p, DeserializationContext ctxt, JavaType bindType) throws IOException { JsonToken t = p.nextToken(); if (t != null) { Class<?> bt = ClassUtil.rawClass(bindType); ctxt.reportTrailingTokens(bt, p, t); } } protected JsonDeserializer<Object> _findRootDeserializer(DeserializationContext ctxt, JavaType valueType) throws JsonMappingException { JsonDeserializer<Object> deser = (JsonDeserializer)this._rootDeserializers.get(valueType); if (deser != null) { return deser; } else { deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { return (JsonDeserializer)ctxt.reportBadDefinition(valueType, "Cannot find a deserializer for type " + valueType); } else { this._rootDeserializers.put(valueType, deser); return deser; } } } protected void _verifySchemaType(FormatSchema schema) { if (schema != null && !this._jsonFactory.canUseSchema(schema)) { throw new IllegalArgumentException("Cannot use FormatSchema of type " + schema.getClass().getName() + " for format " + this._jsonFactory.getFormatName()); } } static { DEFAULT_BASE = new BaseSettings((ClassIntrospector)null, DEFAULT_ANNOTATION_INTROSPECTOR, (PropertyNamingStrategy)null, TypeFactory.defaultInstance(), (TypeResolverBuilder)null, StdDateFormat.instance, (HandlerInstantiator)null, Locale.getDefault(), (TimeZone)null, Base64Variants.getDefaultVariant()); } public static class DefaultTypeResolverBuilder extends StdTypeResolverBuilder implements Serializable { private static final long serialVersionUID = 1L; protected final ObjectMapper.DefaultTyping _appliesFor; public DefaultTypeResolverBuilder(ObjectMapper.DefaultTyping t) { this._appliesFor = t; } public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes) { return this.useForType(baseType) ? super.buildTypeDeserializer(config, baseType, subtypes) : null; } public TypeSerializer buildTypeSerializer(SerializationConfig config, JavaType baseType, Collection<NamedType> subtypes) { return this.useForType(baseType) ? super.buildTypeSerializer(config, baseType, subtypes) : null; } public boolean useForType(JavaType t) { if (t.isPrimitive()) { return false; } else { switch(this._appliesFor) { case NON_CONCRETE_AND_ARRAYS: while(t.isArrayType()) { t = t.getContentType(); } case OBJECT_AND_NON_CONCRETE: break; case NON_FINAL: while(t.isArrayType()) { t = t.getContentType(); } while(t.isReferenceType()) { t = t.getReferencedType(); } return !t.isFinal() && !TreeNode.class.isAssignableFrom(t.getRawClass()); default: return t.isJavaLangObject(); } while(t.isReferenceType()) { t = t.getReferencedType(); } return t.isJavaLangObject() || !t.isConcrete() && !TreeNode.class.isAssignableFrom(t.getRawClass()); } } } public static enum DefaultTyping { JAVA_LANG_OBJECT, OBJECT_AND_NON_CONCRETE, NON_CONCRETE_AND_ARRAYS, NON_FINAL; private DefaultTyping() { } } }
技巧:SpringMVC在启动时就会创建一个ObjectMapper的Bean
1 writeValueAsString
1.1 简述
将一个对象转化成JSON格式的字符串
public String writeValueAsString(Object value) throws JsonProcessingException {
SegmentedStringWriter sw = new SegmentedStringWriter(this._jsonFactory._getBufferRecycler());
try {
this._configAndWriteValue(this._jsonFactory.createGenerator(sw), value);
} catch (JsonProcessingException var4) {
throw var4;
} catch (IOException var5) {
throw JsonMappingException.fromUnexpectedIOE(var5);
}
return sw.getAndClear();
}
1.2 实例
package com.example.wiremock.controller; import com.example.wiremock.entity.properties.BrowserProperty; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; /** * @author 王杨帅 * @create 2018-05-13 19:47 * @desc **/ @RunWith(SpringRunner.class) @SpringBootTest @Slf4j public class ObjectMapperTest { @Autowired private ObjectMapper objectMapper; @Test public void test01() throws JsonProcessingException { // 创建一个对象 BrowserProperty browserProperty = new BrowserProperty(); // 打印输出 log.info(ReflectionToStringBuilder.toString(browserProperty, ToStringStyle.MULTI_LINE_STYLE)); // 对象转化成JSON String result = objectMapper.writeValueAsString(browserProperty); // 打印输出 log.info(result); } }