/** * Customized {@link TypeResolverBuilder} that provides type resolver builders * used with so-called "default typing" * (see {@link ObjectMapper#enableDefaultTyping()} for details). *<p> * Type resolver construction is based on configuration: implementation takes care * of only providing builders in cases where type information should be applied. * This is important since build calls may be sent for any and all types, and * type information should NOT be applied to all of them. */ public static class DefaultTypeResolverBuilder extends StdTypeResolverBuilder { /** * Definition of what types is this default typer valid for. */ protected final DefaultTyping _appliesFor; public DefaultTypeResolverBuilder(DefaultTyping t) { _appliesFor = t; } @Override public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes, BeanProperty property) { return useForType(baseType) ? super.buildTypeDeserializer(config, baseType, subtypes, property) : null; } @Override
/** * Customized {@link TypeResolverBuilder} that provides type resolver builders * used with so-called "default typing" * (see {@link ObjectMapper#enableDefaultTyping()} for details). *<p> * Type resolver construction is based on configuration: implementation takes care * of only providing builders in cases where type information should be applied. * This is important since build calls may be sent for any and all types, and * type information should NOT be applied to all of them. */ public static class DefaultTypeResolverBuilder extends StdTypeResolverBuilder { /** * Definition of what types is this default typer valid for. */ protected final DefaultTyping _appliesFor; public DefaultTypeResolverBuilder(DefaultTyping t) { _appliesFor = t; } @Override public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes, BeanProperty property) { return useForType(baseType) ? super.buildTypeDeserializer(config, baseType, subtypes, property) : null; } @Override
/** * Customized {@link TypeResolverBuilder} that provides type resolver builders * used with so-called "default typing" * (see {@link ObjectMapper#enableDefaultTyping()} for details). *<p> * Type resolver construction is based on configuration: implementation takes care * of only providing builders in cases where type information should be applied. * This is important since build calls may be sent for any and all types, and * type information should NOT be applied to all of them. */ public static class DefaultTypeResolverBuilder extends StdTypeResolverBuilder { /** * Definition of what types is this default typer valid for. */ protected final DefaultTyping _appliesFor; public DefaultTypeResolverBuilder(DefaultTyping t) { _appliesFor = t; } @Override public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes, BeanProperty property) { return useForType(baseType) ? super.buildTypeDeserializer(config, baseType, subtypes, property) : null; } @Override
/** * Customized {@link TypeResolverBuilder} that provides type resolver builders * used with so-called "default typing" * (see {@link ObjectMapper#enableDefaultTyping()} for details). *<p> * Type resolver construction is based on configuration: implementation takes care * of only providing builders in cases where type information should be applied. * This is important since build calls may be sent for any and all types, and * type information should NOT be applied to all of them. */ public static class DefaultTypeResolverBuilder extends StdTypeResolverBuilder { /** * Definition of what types is this default typer valid for. */ protected final DefaultTyping _appliesFor; public DefaultTypeResolverBuilder(DefaultTyping t) { _appliesFor = t; } @Override public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes, BeanProperty property) { return useForType(baseType) ? super.buildTypeDeserializer(config, baseType, subtypes, property) : null; } @Override
m.setVisibilityChecker(VisibilityChecker.Std.defaultInstance() .withFieldVisibility(JsonAutoDetect.Visibility.ANY) .withSetterVisibility(JsonAutoDetect.Visibility.NONE));
public JsonCommandWriter() { mapper = new ObjectMapper(); // Pay attention to fields of objects, not getters mapper.setVisibilityChecker(VisibilityChecker.Std.defaultInstance() .withGetterVisibility(JsonAutoDetect.Visibility.NONE) .withIsGetterVisibility(JsonAutoDetect.Visibility.NONE) .withFieldVisibility(JsonAutoDetect.Visibility.ANY)); SerializationConfig config=mapper.getSerializationConfig(); config.without(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS); // Specialized serializers SimpleModule module = new SimpleModule("insight-json", new Version(1, 7, 2, "insight")); module.addSerializer(Frame.class, new JsonCustomFrameSerializer()); module.addSerializer(FrameId.class, new JsonFrameIdSerializer()); module.addSerializer(TraceId.class, new JsonTraceIdSerializer()); module.addSerializer(ResourceKey.class, new JsonResourceKeySerializer()); module.addSerializer(SparseHistogram.class, new JsonSparseHistogramSerializer()); module.addSerializer(HistogramDefinition.class, new JsonHistogramDefinitionSerializer()); module.addSerializer(ApplicationName.class, new JsonApplicationNameSerializer()); mapper.registerModule(module); }