private static ObjectMapper createCombinedObjectMapper() { return new ObjectMapper() .configure(SerializationFeature.WRAP_ROOT_VALUE, true) .configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true) .setAnnotationIntrospector(createJaxbJacksonAnnotationIntrospector()); }
public ObjectMapperResolver() throws Exception { mapper = new ObjectMapper(); mapper.setDefaultPropertyInclusion(Value.construct(Include.NON_NULL, Include.ALWAYS)); mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(mapper.getTypeFactory())); }
private static JacksonJaxbJsonProvider jacksonJaxbJsonProvider() { JacksonJaxbJsonProvider jacksonJaxbJsonProvider = new JacksonJaxbJsonProvider(); ObjectMapper mapper = new ObjectMapper(); mapper.setDefaultPropertyInclusion(JsonInclude.Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.NON_NULL)); mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(mapper.getTypeFactory())); // Ignore unknown properties so that deployed client remain compatible with future versions of NiFi that add new fields mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); jacksonJaxbJsonProvider.setMapper(mapper); return jacksonJaxbJsonProvider; } }
public static ObjectMapper getMapper() { ObjectMapper mapper = new ObjectMapper(); AnnotationIntrospector aipair = new AnnotationIntrospectorPair ( new JaxbAnnotationIntrospector(), new JacksonAnnotationIntrospector() ); mapper.setAnnotationIntrospector(aipair); //REMOVE: mapper.configure(SerializationConfig.Feature.USE_ANNOTATIONS, true); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); return mapper; } }
private void bindAmazonInfoFilter(ObjectMapper mapper) { SimpleFilterProvider filters = new SimpleFilterProvider(); final String filterName = "exclude-amazon-info-entries"; mapper.setAnnotationIntrospector(new JacksonAnnotationIntrospector() { @Override public Object findFilterId(Annotated a) { if (Map.class.isAssignableFrom(a.getRawType())) { return filterName; } return super.findFilterId(a); } }); filters.addFilter(filterName, new SimpleBeanPropertyFilter() { @Override protected boolean include(BeanPropertyWriter writer) { return true; } @Override protected boolean include(PropertyWriter writer) { return MINI_AMAZON_INFO_INCLUDE_KEYS.contains(writer.getName()); } }); mapper.setFilters(filters); }
objectMapper.setAnnotationIntrospector(this.annotationIntrospector);
public Allure1Plugin() { final SimpleModule module = new XmlParserModule() .addDeserializer(ru.yandex.qatools.allure.model.Status.class, new StatusDeserializer()); xmlMapper = new XmlMapper() .configure(USE_WRAPPER_NAME_AS_PROPERTY_NAME, true) .setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())) .registerModule(module); }
public OkHttpReplicationClient(final NiFiProperties properties) { jsonCodec.setDefaultPropertyInclusion(Value.construct(Include.NON_NULL, Include.ALWAYS)); jsonCodec.setAnnotationIntrospector(new JaxbAnnotationIntrospector(jsonCodec.getTypeFactory())); jsonSerializer = new JsonEntitySerializer(jsonCodec); xmlSerializer = new XmlEntitySerializer(); okHttpClient = createOkHttpClient(properties); }
@Override protected JsonEndpointConfig _configForWriting(final ObjectMapper mapper, final Annotation[] annotations, final Class<?> defaultView) { final AnnotationIntrospector customIntrospector = mapper.getSerializationConfig().getAnnotationIntrospector(); // Set the custom (user) introspector to be the primary one. final ObjectMapper filteringMapper = mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(customIntrospector, new JacksonAnnotationIntrospector() { @Override public Object findFilterId(final Annotated a) { final Object filterId = super.findFilterId(a); if (filterId != null) { return filterId; } if (a instanceof AnnotatedMethod) { final Method method = ((AnnotatedMethod) a).getAnnotated(); // Interested only in getters - trying to obtain "field" name from them. if (ReflectionHelper.isGetter(method)) { return ReflectionHelper.getPropertyName(method); } } if (a instanceof AnnotatedField || a instanceof AnnotatedClass) { return a.getName(); } return null; } })); return super._configForWriting(filteringMapper, annotations, defaultView); }
objectMapper.setAnnotationIntrospector(this.annotationIntrospector);
ObjectMapper mapper = new ObjectMapper(); // either via module mapper.registerModule(new ParanamerModule()); // or by directly assigning annotation introspector (but not both!) mapper.setAnnotationIntrospector(new ParanamerOnJacksonAnnotationIntrospector());
protected final void _setAnnotations(ObjectMapper mapper, Annotations[] annotationsToUse) { AnnotationIntrospector intr; if (annotationsToUse == null || annotationsToUse.length == 0) { intr = AnnotationIntrospector.nopInstance(); } else { intr = _resolveIntrospectors(annotationsToUse); } mapper.setAnnotationIntrospector(intr); } }
private void applyConfigurationPropertiesFilter(ObjectMapper mapper) { mapper.setAnnotationIntrospector( new ConfigurationPropertiesAnnotationIntrospector()); mapper.setFilterProvider(new SimpleFilterProvider() .setDefaultFilter(new ConfigurationPropertiesPropertyFilter())); }
@Override protected JsonEndpointConfig _configForWriting(final ObjectMapper mapper, final Annotation[] annotations, final Class<?> defaultView) { final AnnotationIntrospector customIntrospector = mapper.getSerializationConfig().getAnnotationIntrospector(); // Set the custom (user) introspector to be the primary one. final ObjectMapper filteringMapper = mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(customIntrospector, new JacksonAnnotationIntrospector() { @Override public Object findFilterId(final Annotated a) { final Object filterId = super.findFilterId(a); if (filterId != null) { return filterId; } if (a instanceof AnnotatedMethod) { final Method method = ((AnnotatedMethod) a).getAnnotated(); // Interested only in getters - trying to obtain "field" name from them. if (ReflectionHelper.isGetter(method)) { return ReflectionHelper.getPropertyName(method); } } if (a instanceof AnnotatedField || a instanceof AnnotatedClass) { return a.getName(); } return null; } })); return super._configForWriting(filteringMapper, annotations, defaultView); }
public static void configObjectMapper(ObjectMapper mapper) { AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); mapper.setAnnotationIntrospector(introspector); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); }
private ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setAnnotationIntrospector( new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.configure(SerializationFeature.FLUSH_AFTER_WRITE_VALUE, false); return mapper; }
public JacksonJsonMapper() { mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false); AnnotationIntrospector primary = new JacksonAnnotationIntrospector(); AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(mapper.getTypeFactory()); AnnotationIntrospector pair = AnnotationIntrospectorPair.create(primary, secondary); mapper.setAnnotationIntrospector(pair); }
protected final void _setAnnotations(ObjectMapper mapper, Annotations[] annotationsToUse) { AnnotationIntrospector intr; if (annotationsToUse == null || annotationsToUse.length == 0) { intr = AnnotationIntrospector.nopInstance(); } else { intr = _resolveIntrospectors(annotationsToUse); } mapper.setAnnotationIntrospector(intr); } }
static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setAnnotationIntrospector( new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); return mapper; }
private void setAnnotationIntrospectors(ObjectMapper mapper) { AnnotationIntrospector curSerIntro = mapper.getSerializationConfig().getAnnotationIntrospector(); AnnotationIntrospector newSerIntro = AnnotationIntrospectorPair.pair(curSerIntro, new MaskableSensitiveDataAnnotationIntrospector()); mapper.setAnnotationIntrospector(newSerIntro); } }