Java学习者论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

手机号码,快捷登录

恭喜Java学习者论坛(https://www.javaxxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,购买链接:点击进入购买VIP会员
JAVA高级面试进阶视频教程Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程

Go语言视频零基础入门到精通

Java架构师3期(课件+源码)

Java开发全终端实战租房项目视频教程

SpringBoot2.X入门到高级使用教程

大数据培训第六期全套视频教程

深度学习(CNN RNN GAN)算法原理

Java亿级流量电商系统视频教程

互联网架构师视频教程

年薪50万Spark2.0从入门到精通

年薪50万!人工智能学习路线教程

年薪50万!大数据从入门到精通学习路线年薪50万!机器学习入门到精通视频教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程 MySQL入门到精通教程
查看: 2274|回复: 0

[默认分类] ObjectMapper对象的使用 Object2JSON

[复制链接]
  • TA的每日心情
    开心
    2021-12-13 21:45
  • 签到天数: 15 天

    [LV.4]偶尔看看III

    发表于 2018-5-17 11:02:49 | 显示全部楼层 |阅读模式



      
    1. //
    2. // Source code recreated from a .class file by IntelliJ IDEA
    3. // (powered by Fernflower decompiler)
    4. //
    5. package com.fasterxml.jackson.databind;
    6. import com.fasterxml.jackson.annotation.PropertyAccessor;
    7. import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
    8. import com.fasterxml.jackson.annotation.JsonInclude.Include;
    9. import com.fasterxml.jackson.annotation.JsonInclude.Value;
    10. import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
    11. import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
    12. import com.fasterxml.jackson.core.Base64Variant;
    13. import com.fasterxml.jackson.core.Base64Variants;
    14. import com.fasterxml.jackson.core.FormatSchema;
    15. import com.fasterxml.jackson.core.JsonEncoding;
    16. import com.fasterxml.jackson.core.JsonFactory;
    17. import com.fasterxml.jackson.core.JsonGenerationException;
    18. import com.fasterxml.jackson.core.JsonGenerator;
    19. import com.fasterxml.jackson.core.JsonParseException;
    20. import com.fasterxml.jackson.core.JsonParser;
    21. import com.fasterxml.jackson.core.JsonProcessingException;
    22. import com.fasterxml.jackson.core.JsonToken;
    23. import com.fasterxml.jackson.core.ObjectCodec;
    24. import com.fasterxml.jackson.core.PrettyPrinter;
    25. import com.fasterxml.jackson.core.TreeNode;
    26. import com.fasterxml.jackson.core.Version;
    27. import com.fasterxml.jackson.core.Versioned;
    28. import com.fasterxml.jackson.core.JsonFactory.Feature;
    29. import com.fasterxml.jackson.core.io.CharacterEscapes;
    30. import com.fasterxml.jackson.core.io.SegmentedStringWriter;
    31. import com.fasterxml.jackson.core.type.ResolvedType;
    32. import com.fasterxml.jackson.core.type.TypeReference;
    33. import com.fasterxml.jackson.core.util.ByteArrayBuilder;
    34. import com.fasterxml.jackson.databind.Module.SetupContext;
    35. import com.fasterxml.jackson.databind.cfg.BaseSettings;
    36. import com.fasterxml.jackson.databind.cfg.ConfigOverrides;
    37. import com.fasterxml.jackson.databind.cfg.ContextAttributes;
    38. import com.fasterxml.jackson.databind.cfg.HandlerInstantiator;
    39. import com.fasterxml.jackson.databind.cfg.MutableConfigOverride;
    40. import com.fasterxml.jackson.databind.cfg.PackageVersion;
    41. import com.fasterxml.jackson.databind.deser.BeanDeserializerFactory;
    42. import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier;
    43. import com.fasterxml.jackson.databind.deser.DefaultDeserializationContext;
    44. import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler;
    45. import com.fasterxml.jackson.databind.deser.DeserializerFactory;
    46. import com.fasterxml.jackson.databind.deser.Deserializers;
    47. import com.fasterxml.jackson.databind.deser.KeyDeserializers;
    48. import com.fasterxml.jackson.databind.deser.ValueInstantiators;
    49. import com.fasterxml.jackson.databind.exc.MismatchedInputException;
    50. import com.fasterxml.jackson.databind.introspect.BasicClassIntrospector;
    51. import com.fasterxml.jackson.databind.introspect.ClassIntrospector;
    52. import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
    53. import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver;
    54. import com.fasterxml.jackson.databind.introspect.VisibilityChecker;
    55. import com.fasterxml.jackson.databind.introspect.ClassIntrospector.MixInResolver;
    56. import com.fasterxml.jackson.databind.introspect.VisibilityChecker.Std;
    57. import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
    58. import com.fasterxml.jackson.databind.jsonschema.JsonSchema;
    59. import com.fasterxml.jackson.databind.jsontype.NamedType;
    60. import com.fasterxml.jackson.databind.jsontype.SubtypeResolver;
    61. import com.fasterxml.jackson.databind.jsontype.TypeDeserializer;
    62. import com.fasterxml.jackson.databind.jsontype.TypeIdResolver;
    63. import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder;
    64. import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
    65. import com.fasterxml.jackson.databind.jsontype.impl.StdSubtypeResolver;
    66. import com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder;
    67. import com.fasterxml.jackson.databind.node.ArrayNode;
    68. import com.fasterxml.jackson.databind.node.JsonNodeFactory;
    69. import com.fasterxml.jackson.databind.node.NullNode;
    70. import com.fasterxml.jackson.databind.node.ObjectNode;
    71. import com.fasterxml.jackson.databind.node.POJONode;
    72. import com.fasterxml.jackson.databind.node.TreeTraversingParser;
    73. import com.fasterxml.jackson.databind.ser.BeanSerializerFactory;
    74. import com.fasterxml.jackson.databind.ser.BeanSerializerModifier;
    75. import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;
    76. import com.fasterxml.jackson.databind.ser.FilterProvider;
    77. import com.fasterxml.jackson.databind.ser.SerializerFactory;
    78. import com.fasterxml.jackson.databind.ser.Serializers;
    79. import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.Impl;
    80. import com.fasterxml.jackson.databind.type.SimpleType;
    81. import com.fasterxml.jackson.databind.type.TypeFactory;
    82. import com.fasterxml.jackson.databind.type.TypeModifier;
    83. import com.fasterxml.jackson.databind.util.ClassUtil;
    84. import com.fasterxml.jackson.databind.util.RootNameLookup;
    85. import com.fasterxml.jackson.databind.util.StdDateFormat;
    86. import com.fasterxml.jackson.databind.util.TokenBuffer;
    87. import java.io.Closeable;
    88. import java.io.DataInput;
    89. import java.io.DataOutput;
    90. import java.io.File;
    91. import java.io.IOException;
    92. import java.io.InputStream;
    93. import java.io.OutputStream;
    94. import java.io.Reader;
    95. import java.io.Serializable;
    96. import java.io.Writer;
    97. import java.lang.reflect.Type;
    98. import java.net.URL;
    99. import java.security.AccessController;
    100. import java.security.PrivilegedAction;
    101. import java.text.DateFormat;
    102. import java.util.ArrayList;
    103. import java.util.Collection;
    104. import java.util.Iterator;
    105. import java.util.LinkedHashSet;
    106. import java.util.List;
    107. import java.util.Locale;
    108. import java.util.Map;
    109. import java.util.ServiceLoader;
    110. import java.util.Set;
    111. import java.util.TimeZone;
    112. import java.util.concurrent.ConcurrentHashMap;
    113. import java.util.concurrent.atomic.AtomicReference;
    114. public class ObjectMapper extends ObjectCodec implements Versioned, Serializable {
    115.     private static final long serialVersionUID = 2L;
    116.     private static final JavaType JSON_NODE_TYPE = SimpleType.constructUnsafe(JsonNode.class);
    117.     protected static final AnnotationIntrospector DEFAULT_ANNOTATION_INTROSPECTOR = new JacksonAnnotationIntrospector();
    118.     protected static final BaseSettings DEFAULT_BASE;
    119.     protected final JsonFactory _jsonFactory;
    120.     protected TypeFactory _typeFactory;
    121.     protected InjectableValues _injectableValues;
    122.     protected SubtypeResolver _subtypeResolver;
    123.     protected final ConfigOverrides _configOverrides;
    124.     protected SimpleMixInResolver _mixIns;
    125.     protected SerializationConfig _serializationConfig;
    126.     protected DefaultSerializerProvider _serializerProvider;
    127.     protected SerializerFactory _serializerFactory;
    128.     protected DeserializationConfig _deserializationConfig;
    129.     protected DefaultDeserializationContext _deserializationContext;
    130.     protected Set<Object> _registeredModuleTypes;
    131.     protected final ConcurrentHashMap<JavaType, JsonDeserializer<Object>> _rootDeserializers;
    132.     public ObjectMapper() {
    133.         this((JsonFactory)null, (DefaultSerializerProvider)null, (DefaultDeserializationContext)null);
    134.     }
    135.     public ObjectMapper(JsonFactory jf) {
    136.         this(jf, (DefaultSerializerProvider)null, (DefaultDeserializationContext)null);
    137.     }
    138.     protected ObjectMapper(ObjectMapper src) {
    139.         this._rootDeserializers = new ConcurrentHashMap(64, 0.6F, 2);
    140.         this._jsonFactory = src._jsonFactory.copy();
    141.         this._jsonFactory.setCodec(this);
    142.         this._subtypeResolver = src._subtypeResolver;
    143.         this._typeFactory = src._typeFactory;
    144.         this._injectableValues = src._injectableValues;
    145.         this._configOverrides = src._configOverrides.copy();
    146.         this._mixIns = src._mixIns.copy();
    147.         RootNameLookup rootNames = new RootNameLookup();
    148.         this._serializationConfig = new SerializationConfig(src._serializationConfig, this._mixIns, rootNames, this._configOverrides);
    149.         this._deserializationConfig = new DeserializationConfig(src._deserializationConfig, this._mixIns, rootNames, this._configOverrides);
    150.         this._serializerProvider = src._serializerProvider.copy();
    151.         this._deserializationContext = src._deserializationContext.copy();
    152.         this._serializerFactory = src._serializerFactory;
    153.         Set<Object> reg = src._registeredModuleTypes;
    154.         if (reg == null) {
    155.             this._registeredModuleTypes = null;
    156.         } else {
    157.             this._registeredModuleTypes = new LinkedHashSet(reg);
    158.         }
    159.     }
    160.     public ObjectMapper(JsonFactory jf, DefaultSerializerProvider sp, DefaultDeserializationContext dc) {
    161.         this._rootDeserializers = new ConcurrentHashMap(64, 0.6F, 2);
    162.         if (jf == null) {
    163.             this._jsonFactory = new MappingJsonFactory(this);
    164.         } else {
    165.             this._jsonFactory = jf;
    166.             if (jf.getCodec() == null) {
    167.                 this._jsonFactory.setCodec(this);
    168.             }
    169.         }
    170.         this._subtypeResolver = new StdSubtypeResolver();
    171.         RootNameLookup rootNames = new RootNameLookup();
    172.         this._typeFactory = TypeFactory.defaultInstance();
    173.         SimpleMixInResolver mixins = new SimpleMixInResolver((MixInResolver)null);
    174.         this._mixIns = mixins;
    175.         BaseSettings base = DEFAULT_BASE.withClassIntrospector(this.defaultClassIntrospector());
    176.         this._configOverrides = new ConfigOverrides();
    177.         this._serializationConfig = new SerializationConfig(base, this._subtypeResolver, mixins, rootNames, this._configOverrides);
    178.         this._deserializationConfig = new DeserializationConfig(base, this._subtypeResolver, mixins, rootNames, this._configOverrides);
    179.         boolean needOrder = this._jsonFactory.requiresPropertyOrdering();
    180.         if (needOrder ^ this._serializationConfig.isEnabled(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY)) {
    181.             this.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, needOrder);
    182.         }
    183.         this._serializerProvider = (DefaultSerializerProvider)(sp == null ? new Impl() : sp);
    184.         this._deserializationContext = (DefaultDeserializationContext)(dc == null ? new com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.Impl(BeanDeserializerFactory.instance) : dc);
    185.         this._serializerFactory = BeanSerializerFactory.instance;
    186.     }
    187.     protected ClassIntrospector defaultClassIntrospector() {
    188.         return new BasicClassIntrospector();
    189.     }
    190.     public ObjectMapper copy() {
    191.         this._checkInvalidCopy(ObjectMapper.class);
    192.         return new ObjectMapper(this);
    193.     }
    194.     protected void _checkInvalidCopy(Class<?> exp) {
    195.         if (this.getClass() != exp) {
    196.             throw new IllegalStateException("Failed copy(): " + this.getClass().getName() + " (version: " + this.version() + ") does not override copy(); it has to");
    197.         }
    198.     }
    199.     protected ObjectReader _newReader(DeserializationConfig config) {
    200.         return new ObjectReader(this, config);
    201.     }
    202.     protected ObjectReader _newReader(DeserializationConfig config, JavaType valueType, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues) {
    203.         return new ObjectReader(this, config, valueType, valueToUpdate, schema, injectableValues);
    204.     }
    205.     protected ObjectWriter _newWriter(SerializationConfig config) {
    206.         return new ObjectWriter(this, config);
    207.     }
    208.     protected ObjectWriter _newWriter(SerializationConfig config, FormatSchema schema) {
    209.         return new ObjectWriter(this, config, schema);
    210.     }
    211.     protected ObjectWriter _newWriter(SerializationConfig config, JavaType rootType, PrettyPrinter pp) {
    212.         return new ObjectWriter(this, config, rootType, pp);
    213.     }
    214.     public Version version() {
    215.         return PackageVersion.VERSION;
    216.     }
    217.     public ObjectMapper registerModule(Module module) {
    218.         if (this.isEnabled(MapperFeature.IGNORE_DUPLICATE_MODULE_REGISTRATIONS)) {
    219.             Object typeId = module.getTypeId();
    220.             if (typeId != null) {
    221.                 if (this._registeredModuleTypes == null) {
    222.                     this._registeredModuleTypes = new LinkedHashSet();
    223.                 }
    224.                 if (!this._registeredModuleTypes.add(typeId)) {
    225.                     return this;
    226.                 }
    227.             }
    228.         }
    229.         String name = module.getModuleName();
    230.         if (name == null) {
    231.             throw new IllegalArgumentException("Module without defined name");
    232.         } else {
    233.             Version version = module.version();
    234.             if (version == null) {
    235.                 throw new IllegalArgumentException("Module without defined version");
    236.             } else {
    237.                 module.setupModule(new SetupContext() {
    238.                     public Version getMapperVersion() {
    239.                         return ObjectMapper.this.version();
    240.                     }
    241.                     public <C extends ObjectCodec> C getOwner() {
    242.                         return ObjectMapper.this;
    243.                     }
    244.                     public TypeFactory getTypeFactory() {
    245.                         return ObjectMapper.this._typeFactory;
    246.                     }
    247.                     public boolean isEnabled(MapperFeature f) {
    248.                         return ObjectMapper.this.isEnabled(f);
    249.                     }
    250.                     public boolean isEnabled(DeserializationFeature f) {
    251.                         return ObjectMapper.this.isEnabled(f);
    252.                     }
    253.                     public boolean isEnabled(SerializationFeature f) {
    254.                         return ObjectMapper.this.isEnabled(f);
    255.                     }
    256.                     public boolean isEnabled(Feature f) {
    257.                         return ObjectMapper.this.isEnabled(f);
    258.                     }
    259.                     public boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) {
    260.                         return ObjectMapper.this.isEnabled(f);
    261.                     }
    262.                     public boolean isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f) {
    263.                         return ObjectMapper.this.isEnabled(f);
    264.                     }
    265.                     public MutableConfigOverride configOverride(Class<?> type) {
    266.                         return ObjectMapper.this.configOverride(type);
    267.                     }
    268.                     public void addDeserializers(Deserializers d) {
    269.                         DeserializerFactory df = ObjectMapper.this._deserializationContext._factory.withAdditionalDeserializers(d);
    270.                         ObjectMapper.this._deserializationContext = ObjectMapper.this._deserializationContext.with(df);
    271.                     }
    272.                     public void addKeyDeserializers(KeyDeserializers d) {
    273.                         DeserializerFactory df = ObjectMapper.this._deserializationContext._factory.withAdditionalKeyDeserializers(d);
    274.                         ObjectMapper.this._deserializationContext = ObjectMapper.this._deserializationContext.with(df);
    275.                     }
    276.                     public void addBeanDeserializerModifier(BeanDeserializerModifier modifier) {
    277.                         DeserializerFactory df = ObjectMapper.this._deserializationContext._factory.withDeserializerModifier(modifier);
    278.                         ObjectMapper.this._deserializationContext = ObjectMapper.this._deserializationContext.with(df);
    279.                     }
    280.                     public void addSerializers(Serializers s) {
    281.                         ObjectMapper.this._serializerFactory = ObjectMapper.this._serializerFactory.withAdditionalSerializers(s);
    282.                     }
    283.                     public void addKeySerializers(Serializers s) {
    284.                         ObjectMapper.this._serializerFactory = ObjectMapper.this._serializerFactory.withAdditionalKeySerializers(s);
    285.                     }
    286.                     public void addBeanSerializerModifier(BeanSerializerModifier modifier) {
    287.                         ObjectMapper.this._serializerFactory = ObjectMapper.this._serializerFactory.withSerializerModifier(modifier);
    288.                     }
    289.                     public void addAbstractTypeResolver(AbstractTypeResolver resolver) {
    290.                         DeserializerFactory df = ObjectMapper.this._deserializationContext._factory.withAbstractTypeResolver(resolver);
    291.                         ObjectMapper.this._deserializationContext = ObjectMapper.this._deserializationContext.with(df);
    292.                     }
    293.                     public void addTypeModifier(TypeModifier modifier) {
    294.                         TypeFactory f = ObjectMapper.this._typeFactory;
    295.                         f = f.withModifier(modifier);
    296.                         ObjectMapper.this.setTypeFactory(f);
    297.                     }
    298.                     public void addValueInstantiators(ValueInstantiators instantiators) {
    299.                         DeserializerFactory df = ObjectMapper.this._deserializationContext._factory.withValueInstantiators(instantiators);
    300.                         ObjectMapper.this._deserializationContext = ObjectMapper.this._deserializationContext.with(df);
    301.                     }
    302.                     public void setClassIntrospector(ClassIntrospector ci) {
    303.                         ObjectMapper.this._deserializationConfig = (DeserializationConfig)ObjectMapper.this._deserializationConfig.with(ci);
    304.                         ObjectMapper.this._serializationConfig = (SerializationConfig)ObjectMapper.this._serializationConfig.with(ci);
    305.                     }
    306.                     public void insertAnnotationIntrospector(AnnotationIntrospector ai) {
    307.                         ObjectMapper.this._deserializationConfig = (DeserializationConfig)ObjectMapper.this._deserializationConfig.withInsertedAnnotationIntrospector(ai);
    308.                         ObjectMapper.this._serializationConfig = (SerializationConfig)ObjectMapper.this._serializationConfig.withInsertedAnnotationIntrospector(ai);
    309.                     }
    310.                     public void appendAnnotationIntrospector(AnnotationIntrospector ai) {
    311.                         ObjectMapper.this._deserializationConfig = (DeserializationConfig)ObjectMapper.this._deserializationConfig.withAppendedAnnotationIntrospector(ai);
    312.                         ObjectMapper.this._serializationConfig = (SerializationConfig)ObjectMapper.this._serializationConfig.withAppendedAnnotationIntrospector(ai);
    313.                     }
    314.                     public void registerSubtypes(Class... subtypes) {
    315.                         ObjectMapper.this.registerSubtypes(subtypes);
    316.                     }
    317.                     public void registerSubtypes(NamedType... subtypes) {
    318.                         ObjectMapper.this.registerSubtypes(subtypes);
    319.                     }
    320.                     public void registerSubtypes(Collection<Class<?>> subtypes) {
    321.                         ObjectMapper.this.registerSubtypes(subtypes);
    322.                     }
    323.                     public void setMixInAnnotations(Class<?> target, Class<?> mixinSource) {
    324.                         ObjectMapper.this.addMixIn(target, mixinSource);
    325.                     }
    326.                     public void addDeserializationProblemHandler(DeserializationProblemHandler handler) {
    327.                         ObjectMapper.this.addHandler(handler);
    328.                     }
    329.                     public void setNamingStrategy(PropertyNamingStrategy naming) {
    330.                         ObjectMapper.this.setPropertyNamingStrategy(naming);
    331.                     }
    332.                 });
    333.                 return this;
    334.             }
    335.         }
    336.     }
    337.     public ObjectMapper registerModules(Module... modules) {
    338.         Module[] var2 = modules;
    339.         int var3 = modules.length;
    340.         for(int var4 = 0; var4 < var3; ++var4) {
    341.             Module module = var2[var4];
    342.             this.registerModule(module);
    343.         }
    344.         return this;
    345.     }
    346.     public ObjectMapper registerModules(Iterable<? extends Module> modules) {
    347.         Iterator var2 = modules.iterator();
    348.         while(var2.hasNext()) {
    349.             Module module = (Module)var2.next();
    350.             this.registerModule(module);
    351.         }
    352.         return this;
    353.     }
    354.     public static List<Module> findModules() {
    355.         return findModules((ClassLoader)null);
    356.     }
    357.     public static List<Module> findModules(ClassLoader classLoader) {
    358.         ArrayList<Module> modules = new ArrayList();
    359.         ServiceLoader<Module> loader = secureGetServiceLoader(Module.class, classLoader);
    360.         Iterator var3 = loader.iterator();
    361.         while(var3.hasNext()) {
    362.             Module module = (Module)var3.next();
    363.             modules.add(module);
    364.         }
    365.         return modules;
    366.     }
    367.     private static <T> ServiceLoader<T> secureGetServiceLoader(final Class<T> clazz, final ClassLoader classLoader) {
    368.         SecurityManager sm = System.getSecurityManager();
    369.         if (sm == null) {
    370.             return classLoader == null ? ServiceLoader.load(clazz) : ServiceLoader.load(clazz, classLoader);
    371.         } else {
    372.             return (ServiceLoader)AccessController.doPrivileged(new PrivilegedAction<ServiceLoader<T>>() {
    373.                 public ServiceLoader<T> run() {
    374.                     return classLoader == null ? ServiceLoader.load(clazz) : ServiceLoader.load(clazz, classLoader);
    375.                 }
    376.             });
    377.         }
    378.     }
    379.     public ObjectMapper findAndRegisterModules() {
    380.         return this.registerModules((Iterable)findModules());
    381.     }
    382.     public SerializationConfig getSerializationConfig() {
    383.         return this._serializationConfig;
    384.     }
    385.     public DeserializationConfig getDeserializationConfig() {
    386.         return this._deserializationConfig;
    387.     }
    388.     public DeserializationContext getDeserializationContext() {
    389.         return this._deserializationContext;
    390.     }
    391.     public ObjectMapper setSerializerFactory(SerializerFactory f) {
    392.         this._serializerFactory = f;
    393.         return this;
    394.     }
    395.     public SerializerFactory getSerializerFactory() {
    396.         return this._serializerFactory;
    397.     }
    398.     public ObjectMapper setSerializerProvider(DefaultSerializerProvider p) {
    399.         this._serializerProvider = p;
    400.         return this;
    401.     }
    402.     public SerializerProvider getSerializerProvider() {
    403.         return this._serializerProvider;
    404.     }
    405.     public SerializerProvider getSerializerProviderInstance() {
    406.         return this._serializerProvider(this._serializationConfig);
    407.     }
    408.     public ObjectMapper setMixIns(Map<Class<?>, Class<?>> sourceMixins) {
    409.         this._mixIns.setLocalDefinitions(sourceMixins);
    410.         return this;
    411.     }
    412.     public ObjectMapper addMixIn(Class<?> target, Class<?> mixinSource) {
    413.         this._mixIns.addLocalDefinition(target, mixinSource);
    414.         return this;
    415.     }
    416.     public ObjectMapper setMixInResolver(MixInResolver resolver) {
    417.         SimpleMixInResolver r = this._mixIns.withOverrides(resolver);
    418.         if (r != this._mixIns) {
    419.             this._mixIns = r;
    420.             this._deserializationConfig = new DeserializationConfig(this._deserializationConfig, r);
    421.             this._serializationConfig = new SerializationConfig(this._serializationConfig, r);
    422.         }
    423.         return this;
    424.     }
    425.     public Class<?> findMixInClassFor(Class<?> cls) {
    426.         return this._mixIns.findMixInClassFor(cls);
    427.     }
    428.     public int mixInCount() {
    429.         return this._mixIns.localSize();
    430.     }
    431.     /** @deprecated */
    432.     @Deprecated
    433.     public void setMixInAnnotations(Map<Class<?>, Class<?>> sourceMixins) {
    434.         this.setMixIns(sourceMixins);
    435.     }
    436.     /** @deprecated */
    437.     @Deprecated
    438.     public final void addMixInAnnotations(Class<?> target, Class<?> mixinSource) {
    439.         this.addMixIn(target, mixinSource);
    440.     }
    441.     public VisibilityChecker<?> getVisibilityChecker() {
    442.         return this._serializationConfig.getDefaultVisibilityChecker();
    443.     }
    444.     public ObjectMapper setVisibility(VisibilityChecker<?> vc) {
    445.         this._configOverrides.setDefaultVisibility(vc);
    446.         return this;
    447.     }
    448.     public ObjectMapper setVisibility(PropertyAccessor forMethod, Visibility visibility) {
    449.         VisibilityChecker<?> vc = this._configOverrides.getDefaultVisibility();
    450.         vc = vc.withVisibility(forMethod, visibility);
    451.         this._configOverrides.setDefaultVisibility(vc);
    452.         return this;
    453.     }
    454.     public SubtypeResolver getSubtypeResolver() {
    455.         return this._subtypeResolver;
    456.     }
    457.     public ObjectMapper setSubtypeResolver(SubtypeResolver str) {
    458.         this._subtypeResolver = str;
    459.         this._deserializationConfig = this._deserializationConfig.with(str);
    460.         this._serializationConfig = this._serializationConfig.with(str);
    461.         return this;
    462.     }
    463.     public ObjectMapper setAnnotationIntrospector(AnnotationIntrospector ai) {
    464.         this._serializationConfig = (SerializationConfig)this._serializationConfig.with(ai);
    465.         this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(ai);
    466.         return this;
    467.     }
    468.     public ObjectMapper setAnnotationIntrospectors(AnnotationIntrospector serializerAI, AnnotationIntrospector deserializerAI) {
    469.         this._serializationConfig = (SerializationConfig)this._serializationConfig.with(serializerAI);
    470.         this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(deserializerAI);
    471.         return this;
    472.     }
    473.     public ObjectMapper setPropertyNamingStrategy(PropertyNamingStrategy s) {
    474.         this._serializationConfig = (SerializationConfig)this._serializationConfig.with(s);
    475.         this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(s);
    476.         return this;
    477.     }
    478.     public PropertyNamingStrategy getPropertyNamingStrategy() {
    479.         return this._serializationConfig.getPropertyNamingStrategy();
    480.     }
    481.     public ObjectMapper setDefaultPrettyPrinter(PrettyPrinter pp) {
    482.         this._serializationConfig = this._serializationConfig.withDefaultPrettyPrinter(pp);
    483.         return this;
    484.     }
    485.     /** @deprecated */
    486.     @Deprecated
    487.     public void setVisibilityChecker(VisibilityChecker<?> vc) {
    488.         this.setVisibility(vc);
    489.     }
    490.     public ObjectMapper setSerializationInclusion(Include incl) {
    491.         this.setPropertyInclusion(Value.construct(incl, incl));
    492.         return this;
    493.     }
    494.     /** @deprecated */
    495.     @Deprecated
    496.     public ObjectMapper setPropertyInclusion(Value incl) {
    497.         return this.setDefaultPropertyInclusion(incl);
    498.     }
    499.     public ObjectMapper setDefaultPropertyInclusion(Value incl) {
    500.         this._configOverrides.setDefaultInclusion(incl);
    501.         return this;
    502.     }
    503.     public ObjectMapper setDefaultPropertyInclusion(Include incl) {
    504.         this._configOverrides.setDefaultInclusion(Value.construct(incl, incl));
    505.         return this;
    506.     }
    507.     public ObjectMapper setDefaultSetterInfo(com.fasterxml.jackson.annotation.JsonSetter.Value v) {
    508.         this._configOverrides.setDefaultSetterInfo(v);
    509.         return this;
    510.     }
    511.     public ObjectMapper setDefaultVisibility(com.fasterxml.jackson.annotation.JsonAutoDetect.Value vis) {
    512.         this._configOverrides.setDefaultVisibility(Std.construct(vis));
    513.         return this;
    514.     }
    515.     public ObjectMapper setDefaultMergeable(Boolean b) {
    516.         this._configOverrides.setDefaultMergeable(b);
    517.         return this;
    518.     }
    519.     public ObjectMapper enableDefaultTyping() {
    520.         return this.enableDefaultTyping(ObjectMapper.DefaultTyping.OBJECT_AND_NON_CONCRETE);
    521.     }
    522.     public ObjectMapper enableDefaultTyping(ObjectMapper.DefaultTyping dti) {
    523.         return this.enableDefaultTyping(dti, As.WRAPPER_ARRAY);
    524.     }
    525.     public ObjectMapper enableDefaultTyping(ObjectMapper.DefaultTyping applicability, As includeAs) {
    526.         if (includeAs == As.EXTERNAL_PROPERTY) {
    527.             throw new IllegalArgumentException("Cannot use includeAs of " + includeAs);
    528.         } else {
    529.             TypeResolverBuilder<?> typer = new ObjectMapper.DefaultTypeResolverBuilder(applicability);
    530.             TypeResolverBuilder<?> typer = typer.init(Id.CLASS, (TypeIdResolver)null);
    531.             typer = typer.inclusion(includeAs);
    532.             return this.setDefaultTyping(typer);
    533.         }
    534.     }
    535.     public ObjectMapper enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping applicability, String propertyName) {
    536.         TypeResolverBuilder<?> typer = new ObjectMapper.DefaultTypeResolverBuilder(applicability);
    537.         TypeResolverBuilder<?> typer = typer.init(Id.CLASS, (TypeIdResolver)null);
    538.         typer = typer.inclusion(As.PROPERTY);
    539.         typer = typer.typeProperty(propertyName);
    540.         return this.setDefaultTyping(typer);
    541.     }
    542.     public ObjectMapper disableDefaultTyping() {
    543.         return this.setDefaultTyping((TypeResolverBuilder)null);
    544.     }
    545.     public ObjectMapper setDefaultTyping(TypeResolverBuilder<?> typer) {
    546.         this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(typer);
    547.         this._serializationConfig = (SerializationConfig)this._serializationConfig.with(typer);
    548.         return this;
    549.     }
    550.     public void registerSubtypes(Class... classes) {
    551.         this.getSubtypeResolver().registerSubtypes(classes);
    552.     }
    553.     public void registerSubtypes(NamedType... types) {
    554.         this.getSubtypeResolver().registerSubtypes(types);
    555.     }
    556.     public void registerSubtypes(Collection<Class<?>> subtypes) {
    557.         this.getSubtypeResolver().registerSubtypes(subtypes);
    558.     }
    559.     public MutableConfigOverride configOverride(Class<?> type) {
    560.         return this._configOverrides.findOrCreateOverride(type);
    561.     }
    562.     public TypeFactory getTypeFactory() {
    563.         return this._typeFactory;
    564.     }
    565.     public ObjectMapper setTypeFactory(TypeFactory f) {
    566.         this._typeFactory = f;
    567.         this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(f);
    568.         this._serializationConfig = (SerializationConfig)this._serializationConfig.with(f);
    569.         return this;
    570.     }
    571.     public JavaType constructType(Type t) {
    572.         return this._typeFactory.constructType(t);
    573.     }
    574.     public JsonNodeFactory getNodeFactory() {
    575.         return this._deserializationConfig.getNodeFactory();
    576.     }
    577.     public ObjectMapper setNodeFactory(JsonNodeFactory f) {
    578.         this._deserializationConfig = this._deserializationConfig.with(f);
    579.         return this;
    580.     }
    581.     public ObjectMapper addHandler(DeserializationProblemHandler h) {
    582.         this._deserializationConfig = this._deserializationConfig.withHandler(h);
    583.         return this;
    584.     }
    585.     public ObjectMapper clearProblemHandlers() {
    586.         this._deserializationConfig = this._deserializationConfig.withNoProblemHandlers();
    587.         return this;
    588.     }
    589.     public ObjectMapper setConfig(DeserializationConfig config) {
    590.         this._deserializationConfig = config;
    591.         return this;
    592.     }
    593.     /** @deprecated */
    594.     @Deprecated
    595.     public void setFilters(FilterProvider filterProvider) {
    596.         this._serializationConfig = this._serializationConfig.withFilters(filterProvider);
    597.     }
    598.     public ObjectMapper setFilterProvider(FilterProvider filterProvider) {
    599.         this._serializationConfig = this._serializationConfig.withFilters(filterProvider);
    600.         return this;
    601.     }
    602.     public ObjectMapper setBase64Variant(Base64Variant v) {
    603.         this._serializationConfig = (SerializationConfig)this._serializationConfig.with(v);
    604.         this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(v);
    605.         return this;
    606.     }
    607.     public ObjectMapper setConfig(SerializationConfig config) {
    608.         this._serializationConfig = config;
    609.         return this;
    610.     }
    611.     public JsonFactory getFactory() {
    612.         return this._jsonFactory;
    613.     }
    614.     /** @deprecated */
    615.     @Deprecated
    616.     public JsonFactory getJsonFactory() {
    617.         return this.getFactory();
    618.     }
    619.     public ObjectMapper setDateFormat(DateFormat dateFormat) {
    620.         this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(dateFormat);
    621.         this._serializationConfig = this._serializationConfig.with(dateFormat);
    622.         return this;
    623.     }
    624.     public DateFormat getDateFormat() {
    625.         return this._serializationConfig.getDateFormat();
    626.     }
    627.     public Object setHandlerInstantiator(HandlerInstantiator hi) {
    628.         this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(hi);
    629.         this._serializationConfig = (SerializationConfig)this._serializationConfig.with(hi);
    630.         return this;
    631.     }
    632.     public ObjectMapper setInjectableValues(InjectableValues injectableValues) {
    633.         this._injectableValues = injectableValues;
    634.         return this;
    635.     }
    636.     public InjectableValues getInjectableValues() {
    637.         return this._injectableValues;
    638.     }
    639.     public ObjectMapper setLocale(Locale l) {
    640.         this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(l);
    641.         this._serializationConfig = (SerializationConfig)this._serializationConfig.with(l);
    642.         return this;
    643.     }
    644.     public ObjectMapper setTimeZone(TimeZone tz) {
    645.         this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(tz);
    646.         this._serializationConfig = (SerializationConfig)this._serializationConfig.with(tz);
    647.         return this;
    648.     }
    649.     public boolean isEnabled(MapperFeature f) {
    650.         return this._serializationConfig.isEnabled(f);
    651.     }
    652.     public ObjectMapper configure(MapperFeature f, boolean state) {
    653.         this._serializationConfig = state ? (SerializationConfig)this._serializationConfig.with(new MapperFeature[]{f}) : (SerializationConfig)this._serializationConfig.without(new MapperFeature[]{f});
    654.         this._deserializationConfig = state ? (DeserializationConfig)this._deserializationConfig.with(new MapperFeature[]{f}) : (DeserializationConfig)this._deserializationConfig.without(new MapperFeature[]{f});
    655.         return this;
    656.     }
    657.     public ObjectMapper enable(MapperFeature... f) {
    658.         this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.with(f);
    659.         this._serializationConfig = (SerializationConfig)this._serializationConfig.with(f);
    660.         return this;
    661.     }
    662.     public ObjectMapper disable(MapperFeature... f) {
    663.         this._deserializationConfig = (DeserializationConfig)this._deserializationConfig.without(f);
    664.         this._serializationConfig = (SerializationConfig)this._serializationConfig.without(f);
    665.         return this;
    666.     }
    667.     public boolean isEnabled(SerializationFeature f) {
    668.         return this._serializationConfig.isEnabled(f);
    669.     }
    670.     public ObjectMapper configure(SerializationFeature f, boolean state) {
    671.         this._serializationConfig = state ? this._serializationConfig.with(f) : this._serializationConfig.without(f);
    672.         return this;
    673.     }
    674.     public ObjectMapper enable(SerializationFeature f) {
    675.         this._serializationConfig = this._serializationConfig.with(f);
    676.         return this;
    677.     }
    678.     public ObjectMapper enable(SerializationFeature first, SerializationFeature... f) {
    679.         this._serializationConfig = this._serializationConfig.with(first, f);
    680.         return this;
    681.     }
    682.     public ObjectMapper disable(SerializationFeature f) {
    683.         this._serializationConfig = this._serializationConfig.without(f);
    684.         return this;
    685.     }
    686.     public ObjectMapper disable(SerializationFeature first, SerializationFeature... f) {
    687.         this._serializationConfig = this._serializationConfig.without(first, f);
    688.         return this;
    689.     }
    690.     public boolean isEnabled(DeserializationFeature f) {
    691.         return this._deserializationConfig.isEnabled(f);
    692.     }
    693.     public ObjectMapper configure(DeserializationFeature f, boolean state) {
    694.         this._deserializationConfig = state ? this._deserializationConfig.with(f) : this._deserializationConfig.without(f);
    695.         return this;
    696.     }
    697.     public ObjectMapper enable(DeserializationFeature feature) {
    698.         this._deserializationConfig = this._deserializationConfig.with(feature);
    699.         return this;
    700.     }
    701.     public ObjectMapper enable(DeserializationFeature first, DeserializationFeature... f) {
    702.         this._deserializationConfig = this._deserializationConfig.with(first, f);
    703.         return this;
    704.     }
    705.     public ObjectMapper disable(DeserializationFeature feature) {
    706.         this._deserializationConfig = this._deserializationConfig.without(feature);
    707.         return this;
    708.     }
    709.     public ObjectMapper disable(DeserializationFeature first, DeserializationFeature... f) {
    710.         this._deserializationConfig = this._deserializationConfig.without(first, f);
    711.         return this;
    712.     }
    713.     public boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f) {
    714.         return this._deserializationConfig.isEnabled(f, this._jsonFactory);
    715.     }
    716.     public ObjectMapper configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state) {
    717.         this._jsonFactory.configure(f, state);
    718.         return this;
    719.     }
    720.     public ObjectMapper enable(com.fasterxml.jackson.core.JsonParser.Feature... features) {
    721.         com.fasterxml.jackson.core.JsonParser.Feature[] var2 = features;
    722.         int var3 = features.length;
    723.         for(int var4 = 0; var4 < var3; ++var4) {
    724.             com.fasterxml.jackson.core.JsonParser.Feature f = var2[var4];
    725.             this._jsonFactory.enable(f);
    726.         }
    727.         return this;
    728.     }
    729.     public ObjectMapper disable(com.fasterxml.jackson.core.JsonParser.Feature... features) {
    730.         com.fasterxml.jackson.core.JsonParser.Feature[] var2 = features;
    731.         int var3 = features.length;
    732.         for(int var4 = 0; var4 < var3; ++var4) {
    733.             com.fasterxml.jackson.core.JsonParser.Feature f = var2[var4];
    734.             this._jsonFactory.disable(f);
    735.         }
    736.         return this;
    737.     }
    738.     public boolean isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f) {
    739.         return this._serializationConfig.isEnabled(f, this._jsonFactory);
    740.     }
    741.     public ObjectMapper configure(com.fasterxml.jackson.core.JsonGenerator.Feature f, boolean state) {
    742.         this._jsonFactory.configure(f, state);
    743.         return this;
    744.     }
    745.     public ObjectMapper enable(com.fasterxml.jackson.core.JsonGenerator.Feature... features) {
    746.         com.fasterxml.jackson.core.JsonGenerator.Feature[] var2 = features;
    747.         int var3 = features.length;
    748.         for(int var4 = 0; var4 < var3; ++var4) {
    749.             com.fasterxml.jackson.core.JsonGenerator.Feature f = var2[var4];
    750.             this._jsonFactory.enable(f);
    751.         }
    752.         return this;
    753.     }
    754.     public ObjectMapper disable(com.fasterxml.jackson.core.JsonGenerator.Feature... features) {
    755.         com.fasterxml.jackson.core.JsonGenerator.Feature[] var2 = features;
    756.         int var3 = features.length;
    757.         for(int var4 = 0; var4 < var3; ++var4) {
    758.             com.fasterxml.jackson.core.JsonGenerator.Feature f = var2[var4];
    759.             this._jsonFactory.disable(f);
    760.         }
    761.         return this;
    762.     }
    763.     public boolean isEnabled(Feature f) {
    764.         return this._jsonFactory.isEnabled(f);
    765.     }
    766.     public <T> T readValue(JsonParser p, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException {
    767.         return this._readValue(this.getDeserializationConfig(), p, this._typeFactory.constructType(valueType));
    768.     }
    769.     public <T> T readValue(JsonParser p, TypeReference<?> valueTypeRef) throws IOException, JsonParseException, JsonMappingException {
    770.         return this._readValue(this.getDeserializationConfig(), p, this._typeFactory.constructType(valueTypeRef));
    771.     }
    772.     public final <T> T readValue(JsonParser p, ResolvedType valueType) throws IOException, JsonParseException, JsonMappingException {
    773.         return this._readValue(this.getDeserializationConfig(), p, (JavaType)valueType);
    774.     }
    775.     public <T> T readValue(JsonParser p, JavaType valueType) throws IOException, JsonParseException, JsonMappingException {
    776.         return this._readValue(this.getDeserializationConfig(), p, valueType);
    777.     }
    778.     public <T extends TreeNode> T readTree(JsonParser p) throws IOException, JsonProcessingException {
    779.         DeserializationConfig cfg = this.getDeserializationConfig();
    780.         JsonToken t = p.getCurrentToken();
    781.         if (t == null) {
    782.             t = p.nextToken();
    783.             if (t == null) {
    784.                 return null;
    785.             }
    786.         }
    787.         JsonNode n = (JsonNode)this._readValue(cfg, p, JSON_NODE_TYPE);
    788.         if (n == null) {
    789.             n = this.getNodeFactory().nullNode();
    790.         }
    791.         return (TreeNode)n;
    792.     }
    793.     public <T> MappingIterator<T> readValues(JsonParser p, ResolvedType valueType) throws IOException, JsonProcessingException {
    794.         return this.readValues(p, (JavaType)valueType);
    795.     }
    796.     public <T> MappingIterator<T> readValues(JsonParser p, JavaType valueType) throws IOException, JsonProcessingException {
    797.         DeserializationConfig config = this.getDeserializationConfig();
    798.         DeserializationContext ctxt = this.createDeserializationContext(p, config);
    799.         JsonDeserializer<?> deser = this._findRootDeserializer(ctxt, valueType);
    800.         return new MappingIterator(valueType, p, ctxt, deser, false, (Object)null);
    801.     }
    802.     public <T> MappingIterator<T> readValues(JsonParser p, Class<T> valueType) throws IOException, JsonProcessingException {
    803.         return this.readValues(p, this._typeFactory.constructType(valueType));
    804.     }
    805.     public <T> MappingIterator<T> readValues(JsonParser p, TypeReference<?> valueTypeRef) throws IOException, JsonProcessingException {
    806.         return this.readValues(p, this._typeFactory.constructType(valueTypeRef));
    807.     }
    808.     public JsonNode readTree(InputStream in) throws IOException {
    809.         return this._readTreeAndClose(this._jsonFactory.createParser(in));
    810.     }
    811.     public JsonNode readTree(Reader r) throws IOException {
    812.         return this._readTreeAndClose(this._jsonFactory.createParser(r));
    813.     }
    814.     public JsonNode readTree(String content) throws IOException {
    815.         return this._readTreeAndClose(this._jsonFactory.createParser(content));
    816.     }
    817.     public JsonNode readTree(byte[] content) throws IOException {
    818.         return this._readTreeAndClose(this._jsonFactory.createParser(content));
    819.     }
    820.     public JsonNode readTree(File file) throws IOException, JsonProcessingException {
    821.         return this._readTreeAndClose(this._jsonFactory.createParser(file));
    822.     }
    823.     public JsonNode readTree(URL source) throws IOException {
    824.         return this._readTreeAndClose(this._jsonFactory.createParser(source));
    825.     }
    826.     public void writeValue(JsonGenerator g, Object value) throws IOException, JsonGenerationException, JsonMappingException {
    827.         SerializationConfig config = this.getSerializationConfig();
    828.         if (config.isEnabled(SerializationFeature.INDENT_OUTPUT) && g.getPrettyPrinter() == null) {
    829.             g.setPrettyPrinter(config.constructDefaultPrettyPrinter());
    830.         }
    831.         if (config.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && value instanceof Closeable) {
    832.             this._writeCloseableValue(g, value, config);
    833.         } else {
    834.             this._serializerProvider(config).serializeValue(g, value);
    835.             if (config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) {
    836.                 g.flush();
    837.             }
    838.         }
    839.     }
    840.     public void writeTree(JsonGenerator jgen, TreeNode rootNode) throws IOException, JsonProcessingException {
    841.         SerializationConfig config = this.getSerializationConfig();
    842.         this._serializerProvider(config).serializeValue(jgen, rootNode);
    843.         if (config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) {
    844.             jgen.flush();
    845.         }
    846.     }
    847.     public void writeTree(JsonGenerator jgen, JsonNode rootNode) throws IOException, JsonProcessingException {
    848.         SerializationConfig config = this.getSerializationConfig();
    849.         this._serializerProvider(config).serializeValue(jgen, rootNode);
    850.         if (config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) {
    851.             jgen.flush();
    852.         }
    853.     }
    854.     public ObjectNode createObjectNode() {
    855.         return this._deserializationConfig.getNodeFactory().objectNode();
    856.     }
    857.     public ArrayNode createArrayNode() {
    858.         return this._deserializationConfig.getNodeFactory().arrayNode();
    859.     }
    860.     public JsonParser treeAsTokens(TreeNode n) {
    861.         return new TreeTraversingParser((JsonNode)n, this);
    862.     }
    863.     public <T> T treeToValue(TreeNode n, Class<T> valueType) throws JsonProcessingException {
    864.         try {
    865.             if (valueType != Object.class && valueType.isAssignableFrom(n.getClass())) {
    866.                 return n;
    867.             } else {
    868.                 if (n.asToken() == JsonToken.VALUE_EMBEDDED_OBJECT && n instanceof POJONode) {
    869.                     Object ob = ((POJONode)n).getPojo();
    870.                     if (ob == null || valueType.isInstance(ob)) {
    871.                         return ob;
    872.                     }
    873.                 }
    874.                 return this.readValue(this.treeAsTokens(n), valueType);
    875.             }
    876.         } catch (JsonProcessingException var4) {
    877.             throw var4;
    878.         } catch (IOException var5) {
    879.             throw new IllegalArgumentException(var5.getMessage(), var5);
    880.         }
    881.     }
    882.     public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException {
    883.         if (fromValue == null) {
    884.             return null;
    885.         } else {
    886.             TokenBuffer buf = new TokenBuffer(this, false);
    887.             if (this.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
    888.                 buf = buf.forceUseOfBigDecimal(true);
    889.             }
    890.             try {
    891.                 this.writeValue((JsonGenerator)buf, fromValue);
    892.                 JsonParser p = buf.asParser();
    893.                 JsonNode result = (JsonNode)this.readTree(p);
    894.                 p.close();
    895.                 return result;
    896.             } catch (IOException var5) {
    897.                 throw new IllegalArgumentException(var5.getMessage(), var5);
    898.             }
    899.         }
    900.     }
    901.     public boolean canSerialize(Class<?> type) {
    902.         return this._serializerProvider(this.getSerializationConfig()).hasSerializerFor(type, (AtomicReference)null);
    903.     }
    904.     public boolean canSerialize(Class<?> type, AtomicReference<Throwable> cause) {
    905.         return this._serializerProvider(this.getSerializationConfig()).hasSerializerFor(type, cause);
    906.     }
    907.     public boolean canDeserialize(JavaType type) {
    908.         return this.createDeserializationContext((JsonParser)null, this.getDeserializationConfig()).hasValueDeserializerFor(type, (AtomicReference)null);
    909.     }
    910.     public boolean canDeserialize(JavaType type, AtomicReference<Throwable> cause) {
    911.         return this.createDeserializationContext((JsonParser)null, this.getDeserializationConfig()).hasValueDeserializerFor(type, cause);
    912.     }
    913.     public <T> T readValue(File src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException {
    914.         return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueType));
    915.     }
    916.     public <T> T readValue(File src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException {
    917.         return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueTypeRef));
    918.     }
    919.     public <T> T readValue(File src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException {
    920.         return this._readMapAndClose(this._jsonFactory.createParser(src), valueType);
    921.     }
    922.     public <T> T readValue(URL src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException {
    923.         return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueType));
    924.     }
    925.     public <T> T readValue(URL src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException {
    926.         return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueTypeRef));
    927.     }
    928.     public <T> T readValue(URL src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException {
    929.         return this._readMapAndClose(this._jsonFactory.createParser(src), valueType);
    930.     }
    931.     public <T> T readValue(String content, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException {
    932.         return this._readMapAndClose(this._jsonFactory.createParser(content), this._typeFactory.constructType(valueType));
    933.     }
    934.     public <T> T readValue(String content, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException {
    935.         return this._readMapAndClose(this._jsonFactory.createParser(content), this._typeFactory.constructType(valueTypeRef));
    936.     }
    937.     public <T> T readValue(String content, JavaType valueType) throws IOException, JsonParseException, JsonMappingException {
    938.         return this._readMapAndClose(this._jsonFactory.createParser(content), valueType);
    939.     }
    940.     public <T> T readValue(Reader src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException {
    941.         return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueType));
    942.     }
    943.     public <T> T readValue(Reader src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException {
    944.         return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueTypeRef));
    945.     }
    946.     public <T> T readValue(Reader src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException {
    947.         return this._readMapAndClose(this._jsonFactory.createParser(src), valueType);
    948.     }
    949.     public <T> T readValue(InputStream src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException {
    950.         return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueType));
    951.     }
    952.     public <T> T readValue(InputStream src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException {
    953.         return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueTypeRef));
    954.     }
    955.     public <T> T readValue(InputStream src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException {
    956.         return this._readMapAndClose(this._jsonFactory.createParser(src), valueType);
    957.     }
    958.     public <T> T readValue(byte[] src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException {
    959.         return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueType));
    960.     }
    961.     public <T> T readValue(byte[] src, int offset, int len, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException {
    962.         return this._readMapAndClose(this._jsonFactory.createParser(src, offset, len), this._typeFactory.constructType(valueType));
    963.     }
    964.     public <T> T readValue(byte[] src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException {
    965.         return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueTypeRef));
    966.     }
    967.     public <T> T readValue(byte[] src, int offset, int len, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException {
    968.         return this._readMapAndClose(this._jsonFactory.createParser(src, offset, len), this._typeFactory.constructType(valueTypeRef));
    969.     }
    970.     public <T> T readValue(byte[] src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException {
    971.         return this._readMapAndClose(this._jsonFactory.createParser(src), valueType);
    972.     }
    973.     public <T> T readValue(byte[] src, int offset, int len, JavaType valueType) throws IOException, JsonParseException, JsonMappingException {
    974.         return this._readMapAndClose(this._jsonFactory.createParser(src, offset, len), valueType);
    975.     }
    976.     public <T> T readValue(DataInput src, Class<T> valueType) throws IOException {
    977.         return this._readMapAndClose(this._jsonFactory.createParser(src), this._typeFactory.constructType(valueType));
    978.     }
    979.     public <T> T readValue(DataInput src, JavaType valueType) throws IOException {
    980.         return this._readMapAndClose(this._jsonFactory.createParser(src), valueType);
    981.     }
    982.     public void writeValue(File resultFile, Object value) throws IOException, JsonGenerationException, JsonMappingException {
    983.         this._configAndWriteValue(this._jsonFactory.createGenerator(resultFile, JsonEncoding.UTF8), value);
    984.     }
    985.     public void writeValue(OutputStream out, Object value) throws IOException, JsonGenerationException, JsonMappingException {
    986.         this._configAndWriteValue(this._jsonFactory.createGenerator(out, JsonEncoding.UTF8), value);
    987.     }
    988.     public void writeValue(DataOutput out, Object value) throws IOException {
    989.         this._configAndWriteValue(this._jsonFactory.createGenerator(out, JsonEncoding.UTF8), value);
    990.     }
    991.     public void writeValue(Writer w, Object value) throws IOException, JsonGenerationException, JsonMappingException {
    992.         this._configAndWriteValue(this._jsonFactory.createGenerator(w), value);
    993.     }
    994.     public String writeValueAsString(Object value) throws JsonProcessingException {
    995.         SegmentedStringWriter sw = new SegmentedStringWriter(this._jsonFactory._getBufferRecycler());
    996.         try {
    997.             this._configAndWriteValue(this._jsonFactory.createGenerator(sw), value);
    998.         } catch (JsonProcessingException var4) {
    999.             throw var4;
    1000.         } catch (IOException var5) {
    1001.             throw JsonMappingException.fromUnexpectedIOE(var5);
    1002.         }
    1003.         return sw.getAndClear();
    1004.     }
    1005.     public byte[] writeValueAsBytes(Object value) throws JsonProcessingException {
    1006.         ByteArrayBuilder bb = new ByteArrayBuilder(this._jsonFactory._getBufferRecycler());
    1007.         try {
    1008.             this._configAndWriteValue(this._jsonFactory.createGenerator(bb, JsonEncoding.UTF8), value);
    1009.         } catch (JsonProcessingException var4) {
    1010.             throw var4;
    1011.         } catch (IOException var5) {
    1012.             throw JsonMappingException.fromUnexpectedIOE(var5);
    1013.         }
    1014.         byte[] result = bb.toByteArray();
    1015.         bb.release();
    1016.         return result;
    1017.     }
    1018.     public ObjectWriter writer() {
    1019.         return this._newWriter(this.getSerializationConfig());
    1020.     }
    1021.     public ObjectWriter writer(SerializationFeature feature) {
    1022.         return this._newWriter(this.getSerializationConfig().with(feature));
    1023.     }
    1024.     public ObjectWriter writer(SerializationFeature first, SerializationFeature... other) {
    1025.         return this._newWriter(this.getSerializationConfig().with(first, other));
    1026.     }
    1027.     public ObjectWriter writer(DateFormat df) {
    1028.         return this._newWriter(this.getSerializationConfig().with(df));
    1029.     }
    1030.     public ObjectWriter writerWithView(Class<?> serializationView) {
    1031.         return this._newWriter(this.getSerializationConfig().withView(serializationView));
    1032.     }
    1033.     public ObjectWriter writerFor(Class<?> rootType) {
    1034.         return this._newWriter(this.getSerializationConfig(), rootType == null ? null : this._typeFactory.constructType(rootType), (PrettyPrinter)null);
    1035.     }
    1036.     public ObjectWriter writerFor(TypeReference<?> rootType) {
    1037.         return this._newWriter(this.getSerializationConfig(), rootType == null ? null : this._typeFactory.constructType(rootType), (PrettyPrinter)null);
    1038.     }
    1039.     public ObjectWriter writerFor(JavaType rootType) {
    1040.         return this._newWriter(this.getSerializationConfig(), rootType, (PrettyPrinter)null);
    1041.     }
    1042.     public ObjectWriter writer(PrettyPrinter pp) {
    1043.         if (pp == null) {
    1044.             pp = ObjectWriter.NULL_PRETTY_PRINTER;
    1045.         }
    1046.         return this._newWriter(this.getSerializationConfig(), (JavaType)null, pp);
    1047.     }
    1048.     public ObjectWriter writerWithDefaultPrettyPrinter() {
    1049.         SerializationConfig config = this.getSerializationConfig();
    1050.         return this._newWriter(config, (JavaType)null, config.getDefaultPrettyPrinter());
    1051.     }
    1052.     public ObjectWriter writer(FilterProvider filterProvider) {
    1053.         return this._newWriter(this.getSerializationConfig().withFilters(filterProvider));
    1054.     }
    1055.     public ObjectWriter writer(FormatSchema schema) {
    1056.         this._verifySchemaType(schema);
    1057.         return this._newWriter(this.getSerializationConfig(), schema);
    1058.     }
    1059.     public ObjectWriter writer(Base64Variant defaultBase64) {
    1060.         return this._newWriter((SerializationConfig)this.getSerializationConfig().with(defaultBase64));
    1061.     }
    1062.     public ObjectWriter writer(CharacterEscapes escapes) {
    1063.         return this._newWriter(this.getSerializationConfig()).with(escapes);
    1064.     }
    1065.     public ObjectWriter writer(ContextAttributes attrs) {
    1066.         return this._newWriter(this.getSerializationConfig().with(attrs));
    1067.     }
    1068.     /** @deprecated */
    1069.     @Deprecated
    1070.     public ObjectWriter writerWithType(Class<?> rootType) {
    1071.         return this._newWriter(this.getSerializationConfig(), rootType == null ? null : this._typeFactory.constructType(rootType), (PrettyPrinter)null);
    1072.     }
    1073.     /** @deprecated */
    1074.     @Deprecated
    1075.     public ObjectWriter writerWithType(TypeReference<?> rootType) {
    1076.         return this._newWriter(this.getSerializationConfig(), rootType == null ? null : this._typeFactory.constructType(rootType), (PrettyPrinter)null);
    1077.     }
    1078.     /** @deprecated */
    1079.     @Deprecated
    1080.     public ObjectWriter writerWithType(JavaType rootType) {
    1081.         return this._newWriter(this.getSerializationConfig(), rootType, (PrettyPrinter)null);
    1082.     }
    1083.     public ObjectReader reader() {
    1084.         return this._newReader(this.getDeserializationConfig()).with(this._injectableValues);
    1085.     }
    1086.     public ObjectReader reader(DeserializationFeature feature) {
    1087.         return this._newReader(this.getDeserializationConfig().with(feature));
    1088.     }
    1089.     public ObjectReader reader(DeserializationFeature first, DeserializationFeature... other) {
    1090.         return this._newReader(this.getDeserializationConfig().with(first, other));
    1091.     }
    1092.     public ObjectReader readerForUpdating(Object valueToUpdate) {
    1093.         JavaType t = this._typeFactory.constructType(valueToUpdate.getClass());
    1094.         return this._newReader(this.getDeserializationConfig(), t, valueToUpdate, (FormatSchema)null, this._injectableValues);
    1095.     }
    1096.     public ObjectReader readerFor(JavaType type) {
    1097.         return this._newReader(this.getDeserializationConfig(), type, (Object)null, (FormatSchema)null, this._injectableValues);
    1098.     }
    1099.     public ObjectReader readerFor(Class<?> type) {
    1100.         return this._newReader(this.getDeserializationConfig(), this._typeFactory.constructType(type), (Object)null, (FormatSchema)null, this._injectableValues);
    1101.     }
    1102.     public ObjectReader readerFor(TypeReference<?> type) {
    1103.         return this._newReader(this.getDeserializationConfig(), this._typeFactory.constructType(type), (Object)null, (FormatSchema)null, this._injectableValues);
    1104.     }
    1105.     public ObjectReader reader(JsonNodeFactory f) {
    1106.         return this._newReader(this.getDeserializationConfig()).with(f);
    1107.     }
    1108.     public ObjectReader reader(FormatSchema schema) {
    1109.         this._verifySchemaType(schema);
    1110.         return this._newReader(this.getDeserializationConfig(), (JavaType)null, (Object)null, schema, this._injectableValues);
    1111.     }
    1112.     public ObjectReader reader(InjectableValues injectableValues) {
    1113.         return this._newReader(this.getDeserializationConfig(), (JavaType)null, (Object)null, (FormatSchema)null, injectableValues);
    1114.     }
    1115.     public ObjectReader readerWithView(Class<?> view) {
    1116.         return this._newReader(this.getDeserializationConfig().withView(view));
    1117.     }
    1118.     public ObjectReader reader(Base64Variant defaultBase64) {
    1119.         return this._newReader((DeserializationConfig)this.getDeserializationConfig().with(defaultBase64));
    1120.     }
    1121.     public ObjectReader reader(ContextAttributes attrs) {
    1122.         return this._newReader(this.getDeserializationConfig().with(attrs));
    1123.     }
    1124.     /** @deprecated */
    1125.     @Deprecated
    1126.     public ObjectReader reader(JavaType type) {
    1127.         return this._newReader(this.getDeserializationConfig(), type, (Object)null, (FormatSchema)null, this._injectableValues);
    1128.     }
    1129.     /** @deprecated */
    1130.     @Deprecated
    1131.     public ObjectReader reader(Class<?> type) {
    1132.         return this._newReader(this.getDeserializationConfig(), this._typeFactory.constructType(type), (Object)null, (FormatSchema)null, this._injectableValues);
    1133.     }
    1134.     /** @deprecated */
    1135.     @Deprecated
    1136.     public ObjectReader reader(TypeReference<?> type) {
    1137.         return this._newReader(this.getDeserializationConfig(), this._typeFactory.constructType(type), (Object)null, (FormatSchema)null, this._injectableValues);
    1138.     }
    1139.     public <T> T convertValue(Object fromValue, Class<T> toValueType) throws IllegalArgumentException {
    1140.         return this._convert(fromValue, this._typeFactory.constructType(toValueType));
    1141.     }
    1142.     public <T> T convertValue(Object fromValue, TypeReference<?> toValueTypeRef) throws IllegalArgumentException {
    1143.         return this._convert(fromValue, this._typeFactory.constructType(toValueTypeRef));
    1144.     }
    1145.     public <T> T convertValue(Object fromValue, JavaType toValueType) throws IllegalArgumentException {
    1146.         return this._convert(fromValue, toValueType);
    1147.     }
    1148.     protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException {
    1149.         if (fromValue != null) {
    1150.             Class<?> targetType = toValueType.getRawClass();
    1151.             if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) {
    1152.                 return fromValue;
    1153.             }
    1154.         }
    1155.         TokenBuffer buf = new TokenBuffer(this, false);
    1156.         if (this.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
    1157.             buf = buf.forceUseOfBigDecimal(true);
    1158.         }
    1159.         try {
    1160.             SerializationConfig config = this.getSerializationConfig().without(SerializationFeature.WRAP_ROOT_VALUE);
    1161.             this._serializerProvider(config).serializeValue(buf, fromValue);
    1162.             JsonParser p = buf.asParser();
    1163.             DeserializationConfig deserConfig = this.getDeserializationConfig();
    1164.             JsonToken t = this._initForReading(p, toValueType);
    1165.             Object result;
    1166.             DefaultDeserializationContext ctxt;
    1167.             if (t == JsonToken.VALUE_NULL) {
    1168.                 ctxt = this.createDeserializationContext(p, deserConfig);
    1169.                 result = this._findRootDeserializer(ctxt, toValueType).getNullValue(ctxt);
    1170.             } else if (t != JsonToken.END_ARRAY && t != JsonToken.END_OBJECT) {
    1171.                 ctxt = this.createDeserializationContext(p, deserConfig);
    1172.                 JsonDeserializer<Object> deser = this._findRootDeserializer(ctxt, toValueType);
    1173.                 result = deser.deserialize(p, ctxt);
    1174.             } else {
    1175.                 result = null;
    1176.             }
    1177.             p.close();
    1178.             return result;
    1179.         } catch (IOException var11) {
    1180.             throw new IllegalArgumentException(var11.getMessage(), var11);
    1181.         }
    1182.     }
    1183.     public <T> T updateValue(T valueToUpdate, Object overrides) throws JsonMappingException {
    1184.         T result = valueToUpdate;
    1185.         if (valueToUpdate != null && overrides != null) {
    1186.             TokenBuffer buf = new TokenBuffer(this, false);
    1187.             if (this.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
    1188.                 buf = buf.forceUseOfBigDecimal(true);
    1189.             }
    1190.             try {
    1191.                 SerializationConfig config = this.getSerializationConfig().without(SerializationFeature.WRAP_ROOT_VALUE);
    1192.                 this._serializerProvider(config).serializeValue(buf, overrides);
    1193.                 JsonParser p = buf.asParser();
    1194.                 result = this.readerForUpdating(valueToUpdate).readValue(p);
    1195.                 p.close();
    1196.             } catch (IOException var7) {
    1197.                 if (var7 instanceof JsonMappingException) {
    1198.                     throw (JsonMappingException)var7;
    1199.                 }
    1200.                 throw JsonMappingException.fromUnexpectedIOE(var7);
    1201.             }
    1202.         }
    1203.         return result;
    1204.     }
    1205.     /** @deprecated */
    1206.     @Deprecated
    1207.     public JsonSchema generateJsonSchema(Class<?> t) throws JsonMappingException {
    1208.         return this._serializerProvider(this.getSerializationConfig()).generateJsonSchema(t);
    1209.     }
    1210.     public void acceptJsonFormatVisitor(Class<?> type, JsonFormatVisitorWrapper visitor) throws JsonMappingException {
    1211.         this.acceptJsonFormatVisitor(this._typeFactory.constructType(type), visitor);
    1212.     }
    1213.     public void acceptJsonFormatVisitor(JavaType type, JsonFormatVisitorWrapper visitor) throws JsonMappingException {
    1214.         if (type == null) {
    1215.             throw new IllegalArgumentException("type must be provided");
    1216.         } else {
    1217.             this._serializerProvider(this.getSerializationConfig()).acceptJsonFormatVisitor(type, visitor);
    1218.         }
    1219.     }
    1220.     protected DefaultSerializerProvider _serializerProvider(SerializationConfig config) {
    1221.         return this._serializerProvider.createInstance(config, this._serializerFactory);
    1222.     }
    1223.     protected final void _configAndWriteValue(JsonGenerator g, Object value) throws IOException {
    1224.         SerializationConfig cfg = this.getSerializationConfig();
    1225.         cfg.initialize(g);
    1226.         if (cfg.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && value instanceof Closeable) {
    1227.             this._configAndWriteCloseable(g, value, cfg);
    1228.         } else {
    1229.             try {
    1230.                 this._serializerProvider(cfg).serializeValue(g, value);
    1231.             } catch (Exception var5) {
    1232.                 ClassUtil.closeOnFailAndThrowAsIOE(g, var5);
    1233.                 return;
    1234.             }
    1235.             g.close();
    1236.         }
    1237.     }
    1238.     private final void _configAndWriteCloseable(JsonGenerator g, Object value, SerializationConfig cfg) throws IOException {
    1239.         Closeable toClose = (Closeable)value;
    1240.         try {
    1241.             this._serializerProvider(cfg).serializeValue(g, value);
    1242.             Closeable tmpToClose = toClose;
    1243.             toClose = null;
    1244.             tmpToClose.close();
    1245.         } catch (Exception var6) {
    1246.             ClassUtil.closeOnFailAndThrowAsIOE(g, toClose, var6);
    1247.             return;
    1248.         }
    1249.         g.close();
    1250.     }
    1251.     private final void _writeCloseableValue(JsonGenerator g, Object value, SerializationConfig cfg) throws IOException {
    1252.         Closeable toClose = (Closeable)value;
    1253.         try {
    1254.             this._serializerProvider(cfg).serializeValue(g, value);
    1255.             if (cfg.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) {
    1256.                 g.flush();
    1257.             }
    1258.         } catch (Exception var6) {
    1259.             ClassUtil.closeOnFailAndThrowAsIOE((JsonGenerator)null, toClose, var6);
    1260.             return;
    1261.         }
    1262.         toClose.close();
    1263.     }
    1264.     protected Object _readValue(DeserializationConfig cfg, JsonParser p, JavaType valueType) throws IOException {
    1265.         JsonToken t = this._initForReading(p, valueType);
    1266.         DeserializationContext ctxt = this.createDeserializationContext(p, cfg);
    1267.         Object result;
    1268.         if (t == JsonToken.VALUE_NULL) {
    1269.             result = this._findRootDeserializer(ctxt, valueType).getNullValue(ctxt);
    1270.         } else if (t != JsonToken.END_ARRAY && t != JsonToken.END_OBJECT) {
    1271.             JsonDeserializer<Object> deser = this._findRootDeserializer(ctxt, valueType);
    1272.             if (cfg.useRootWrapping()) {
    1273.                 result = this._unwrapAndDeserialize(p, ctxt, cfg, valueType, deser);
    1274.             } else {
    1275.                 result = deser.deserialize(p, ctxt);
    1276.             }
    1277.         } else {
    1278.             result = null;
    1279.         }
    1280.         p.clearCurrentToken();
    1281.         if (cfg.isEnabled(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)) {
    1282.             this._verifyNoTrailingTokens(p, ctxt, valueType);
    1283.         }
    1284.         return result;
    1285.     }
    1286.     protected Object _readMapAndClose(JsonParser p0, JavaType valueType) throws IOException {
    1287.         JsonParser p = p0;
    1288.         Throwable var4 = null;
    1289.         Object var20;
    1290.         try {
    1291.             JsonToken t = this._initForReading(p, valueType);
    1292.             DeserializationConfig cfg = this.getDeserializationConfig();
    1293.             DeserializationContext ctxt = this.createDeserializationContext(p, cfg);
    1294.             Object result;
    1295.             if (t == JsonToken.VALUE_NULL) {
    1296.                 result = this._findRootDeserializer(ctxt, valueType).getNullValue(ctxt);
    1297.             } else if (t != JsonToken.END_ARRAY && t != JsonToken.END_OBJECT) {
    1298.                 JsonDeserializer<Object> deser = this._findRootDeserializer(ctxt, valueType);
    1299.                 if (cfg.useRootWrapping()) {
    1300.                     result = this._unwrapAndDeserialize(p, ctxt, cfg, valueType, deser);
    1301.                 } else {
    1302.                     result = deser.deserialize(p, ctxt);
    1303.                 }
    1304.                 ctxt.checkUnresolvedObjectId();
    1305.             } else {
    1306.                 result = null;
    1307.             }
    1308.             if (cfg.isEnabled(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)) {
    1309.                 this._verifyNoTrailingTokens(p, ctxt, valueType);
    1310.             }
    1311.             var20 = result;
    1312.         } catch (Throwable var18) {
    1313.             var4 = var18;
    1314.             throw var18;
    1315.         } finally {
    1316.             if (p0 != null) {
    1317.                 if (var4 != null) {
    1318.                     try {
    1319.                         p.close();
    1320.                     } catch (Throwable var17) {
    1321.                         var4.addSuppressed(var17);
    1322.                     }
    1323.                 } else {
    1324.                     p0.close();
    1325.                 }
    1326.             }
    1327.         }
    1328.         return var20;
    1329.     }
    1330.     protected JsonNode _readTreeAndClose(JsonParser p0) throws IOException {
    1331.         JsonParser p = p0;
    1332.         Throwable var3 = null;
    1333.         NullNode var7;
    1334.         try {
    1335.             JavaType valueType = JSON_NODE_TYPE;
    1336.             DeserializationConfig cfg = this.getDeserializationConfig();
    1337.             cfg.initialize(p);
    1338.             JsonToken t = p.getCurrentToken();
    1339.             if (t == null) {
    1340.                 t = p.nextToken();
    1341.                 if (t == null) {
    1342.                     var7 = null;
    1343.                     return var7;
    1344.                 }
    1345.             }
    1346.             if (t != JsonToken.VALUE_NULL) {
    1347.                 DeserializationContext ctxt = this.createDeserializationContext(p, cfg);
    1348.                 JsonDeserializer<Object> deser = this._findRootDeserializer(ctxt, valueType);
    1349.                 Object result;
    1350.                 if (cfg.useRootWrapping()) {
    1351.                     result = this._unwrapAndDeserialize(p, ctxt, cfg, valueType, deser);
    1352.                 } else {
    1353.                     result = deser.deserialize(p, ctxt);
    1354.                     if (cfg.isEnabled(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)) {
    1355.                         this._verifyNoTrailingTokens(p, ctxt, valueType);
    1356.                     }
    1357.                 }
    1358.                 JsonNode var10 = (JsonNode)result;
    1359.                 return var10;
    1360.             }
    1361.             var7 = cfg.getNodeFactory().nullNode();
    1362.         } catch (Throwable var21) {
    1363.             var3 = var21;
    1364.             throw var21;
    1365.         } finally {
    1366.             if (p0 != null) {
    1367.                 if (var3 != null) {
    1368.                     try {
    1369.                         p.close();
    1370.                     } catch (Throwable var20) {
    1371.                         var3.addSuppressed(var20);
    1372.                     }
    1373.                 } else {
    1374.                     p0.close();
    1375.                 }
    1376.             }
    1377.         }
    1378.         return var7;
    1379.     }
    1380.     protected Object _unwrapAndDeserialize(JsonParser p, DeserializationContext ctxt, DeserializationConfig config, JavaType rootType, JsonDeserializer<Object> deser) throws IOException {
    1381.         PropertyName expRootName = config.findRootName(rootType);
    1382.         String expSimpleName = expRootName.getSimpleName();
    1383.         if (p.getCurrentToken() != JsonToken.START_OBJECT) {
    1384.             ctxt.reportWrongTokenException(rootType, JsonToken.START_OBJECT, "Current token not START_OBJECT (needed to unwrap root name "%s"), but %s", new Object[]{expSimpleName, p.getCurrentToken()});
    1385.         }
    1386.         if (p.nextToken() != JsonToken.FIELD_NAME) {
    1387.             ctxt.reportWrongTokenException(rootType, JsonToken.FIELD_NAME, "Current token not FIELD_NAME (to contain expected root name "%s"), but %s", new Object[]{expSimpleName, p.getCurrentToken()});
    1388.         }
    1389.         String actualName = p.getCurrentName();
    1390.         if (!expSimpleName.equals(actualName)) {
    1391.             ctxt.reportInputMismatch(rootType, "Root name "%s" does not match expected ("%s") for type %s", new Object[]{actualName, expSimpleName, rootType});
    1392.         }
    1393.         p.nextToken();
    1394.         Object result = deser.deserialize(p, ctxt);
    1395.         if (p.nextToken() != JsonToken.END_OBJECT) {
    1396.             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()});
    1397.         }
    1398.         if (config.isEnabled(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)) {
    1399.             this._verifyNoTrailingTokens(p, ctxt, rootType);
    1400.         }
    1401.         return result;
    1402.     }
    1403.     protected DefaultDeserializationContext createDeserializationContext(JsonParser p, DeserializationConfig cfg) {
    1404.         return this._deserializationContext.createInstance(cfg, p, this._injectableValues);
    1405.     }
    1406.     protected JsonToken _initForReading(JsonParser p, JavaType targetType) throws IOException {
    1407.         this._deserializationConfig.initialize(p);
    1408.         JsonToken t = p.getCurrentToken();
    1409.         if (t == null) {
    1410.             t = p.nextToken();
    1411.             if (t == null) {
    1412.                 throw MismatchedInputException.from(p, targetType, "No content to map due to end-of-input");
    1413.             }
    1414.         }
    1415.         return t;
    1416.     }
    1417.     /** @deprecated */
    1418.     @Deprecated
    1419.     protected JsonToken _initForReading(JsonParser p) throws IOException {
    1420.         return this._initForReading(p, (JavaType)null);
    1421.     }
    1422.     protected final void _verifyNoTrailingTokens(JsonParser p, DeserializationContext ctxt, JavaType bindType) throws IOException {
    1423.         JsonToken t = p.nextToken();
    1424.         if (t != null) {
    1425.             Class<?> bt = ClassUtil.rawClass(bindType);
    1426.             ctxt.reportTrailingTokens(bt, p, t);
    1427.         }
    1428.     }
    1429.     protected JsonDeserializer<Object> _findRootDeserializer(DeserializationContext ctxt, JavaType valueType) throws JsonMappingException {
    1430.         JsonDeserializer<Object> deser = (JsonDeserializer)this._rootDeserializers.get(valueType);
    1431.         if (deser != null) {
    1432.             return deser;
    1433.         } else {
    1434.             deser = ctxt.findRootValueDeserializer(valueType);
    1435.             if (deser == null) {
    1436.                 return (JsonDeserializer)ctxt.reportBadDefinition(valueType, "Cannot find a deserializer for type " + valueType);
    1437.             } else {
    1438.                 this._rootDeserializers.put(valueType, deser);
    1439.                 return deser;
    1440.             }
    1441.         }
    1442.     }
    1443.     protected void _verifySchemaType(FormatSchema schema) {
    1444.         if (schema != null && !this._jsonFactory.canUseSchema(schema)) {
    1445.             throw new IllegalArgumentException("Cannot use FormatSchema of type " + schema.getClass().getName() + " for format " + this._jsonFactory.getFormatName());
    1446.         }
    1447.     }
    1448.     static {
    1449.         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());
    1450.     }
    1451.     public static class DefaultTypeResolverBuilder extends StdTypeResolverBuilder implements Serializable {
    1452.         private static final long serialVersionUID = 1L;
    1453.         protected final ObjectMapper.DefaultTyping _appliesFor;
    1454.         public DefaultTypeResolverBuilder(ObjectMapper.DefaultTyping t) {
    1455.             this._appliesFor = t;
    1456.         }
    1457.         public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes) {
    1458.             return this.useForType(baseType) ? super.buildTypeDeserializer(config, baseType, subtypes) : null;
    1459.         }
    1460.         public TypeSerializer buildTypeSerializer(SerializationConfig config, JavaType baseType, Collection<NamedType> subtypes) {
    1461.             return this.useForType(baseType) ? super.buildTypeSerializer(config, baseType, subtypes) : null;
    1462.         }
    1463.         public boolean useForType(JavaType t) {
    1464.             if (t.isPrimitive()) {
    1465.                 return false;
    1466.             } else {
    1467.                 switch(this._appliesFor) {
    1468.                 case NON_CONCRETE_AND_ARRAYS:
    1469.                     while(t.isArrayType()) {
    1470.                         t = t.getContentType();
    1471.                     }
    1472.                 case OBJECT_AND_NON_CONCRETE:
    1473.                     break;
    1474.                 case NON_FINAL:
    1475.                     while(t.isArrayType()) {
    1476.                         t = t.getContentType();
    1477.                     }
    1478.                     while(t.isReferenceType()) {
    1479.                         t = t.getReferencedType();
    1480.                     }
    1481.                     return !t.isFinal() && !TreeNode.class.isAssignableFrom(t.getRawClass());
    1482.                 default:
    1483.                     return t.isJavaLangObject();
    1484.                 }
    1485.                 while(t.isReferenceType()) {
    1486.                     t = t.getReferencedType();
    1487.                 }
    1488.                 return t.isJavaLangObject() || !t.isConcrete() && !TreeNode.class.isAssignableFrom(t.getRawClass());
    1489.             }
    1490.         }
    1491.     }
    1492.     public static enum DefaultTyping {
    1493.         JAVA_LANG_OBJECT,
    1494.         OBJECT_AND_NON_CONCRETE,
    1495.         NON_CONCRETE_AND_ARRAYS,
    1496.         NON_FINAL;
    1497.         private DefaultTyping() {
    1498.         }
    1499.     }
    1500. }
    复制代码

      
    ObjectMapper.java

    技巧:SpringMVC在启动时就会创建一个ObjectMapper的Bean  
      
    1 writeValueAsString
      1.1 简述
        将一个对象转化成JSON格式的字符串

    1.     public String writeValueAsString(Object value) throws JsonProcessingException {
    2.         SegmentedStringWriter sw = new SegmentedStringWriter(this._jsonFactory._getBufferRecycler());
    3.         try {
    4.             this._configAndWriteValue(this._jsonFactory.createGenerator(sw), value);
    5.         } catch (JsonProcessingException var4) {
    6.             throw var4;
    7.         } catch (IOException var5) {
    8.             throw JsonMappingException.fromUnexpectedIOE(var5);
    9.         }
    10.         return sw.getAndClear();
    11.     }
    复制代码


      1.2 实例



      
    1. package com.example.wiremock.controller;
    2. import com.example.wiremock.entity.properties.BrowserProperty;
    3. import com.fasterxml.jackson.core.JsonProcessingException;
    4. import com.fasterxml.jackson.databind.ObjectMapper;
    5. import lombok.extern.slf4j.Slf4j;
    6. import org.apache.commons.lang.builder.ReflectionToStringBuilder;
    7. import org.apache.commons.lang.builder.ToStringStyle;
    8. import org.junit.Test;
    9. import org.junit.runner.RunWith;
    10. import org.springframework.beans.factory.annotation.Autowired;
    11. import org.springframework.boot.test.context.SpringBootTest;
    12. import org.springframework.test.context.junit4.SpringRunner;
    13. /**
    14. * @author 王杨帅
    15. * @create 2018-05-13 19:47
    16. * @desc
    17. **/
    18. @RunWith(SpringRunner.class)
    19. @SpringBootTest
    20. @Slf4j
    21. public class ObjectMapperTest {
    22.     @Autowired
    23.     private ObjectMapper objectMapper;
    24.     @Test
    25.     public void test01() throws JsonProcessingException {
    26.         // 创建一个对象
    27.         BrowserProperty browserProperty = new BrowserProperty();
    28.         // 打印输出
    29.         log.info(ReflectionToStringBuilder.toString(browserProperty, ToStringStyle.MULTI_LINE_STYLE));
    30.         // 对象转化成JSON
    31.         String result = objectMapper.writeValueAsString(browserProperty);
    32.         // 打印输出
    33.         log.info(result);
    34.     }
    35. }
    复制代码

      
    ObjectMapperTest.java

    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|Java学习者论坛 ( 声明:本站资料整理自互联网,用于Java学习者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2024-4-19 22:14 , Processed in 0.415762 second(s), 38 queries .

    Powered by Discuz! X3.4

    © 2001-2017 Comsenz Inc.

    快速回复 返回顶部 返回列表