List of usage examples for com.fasterxml.jackson.databind.introspect JacksonAnnotationIntrospector JacksonAnnotationIntrospector
JacksonAnnotationIntrospector
From source file:com.infinities.keystone4j.utils.jackson.JacksonProvider.java
public JacksonProvider() { AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); // if using BOTH JAXB annotations AND Jackson annotations: AnnotationIntrospector secondary = new JacksonAnnotationIntrospector(); ObjectMapper mapper = new ObjectMapper().registerModule(new Hibernate4Module()) .setSerializationInclusion(Include.NON_NULL) .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .enable(SerializationFeature.INDENT_OUTPUT) .setAnnotationIntrospector(new AnnotationIntrospectorPair(introspector, secondary)); // mapper = mapper.setSerializationInclusion(Include) setMapper(mapper);// www. j a va 2 s.c o m }
From source file:com.ning.billing.recurly.model.RecurlyObject.java
public static XmlMapper newXmlMapper() { final XmlMapper xmlMapper = new XmlMapper(); xmlMapper.setSerializerProvider(new RecurlyXmlSerializerProvider()); final AnnotationIntrospector primary = new JacksonAnnotationIntrospector(); final AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); final AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary); xmlMapper.setAnnotationIntrospector(pair); xmlMapper.registerModule(new JodaModule()); xmlMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); final SimpleModule m = new SimpleModule("module", new Version(1, 0, 0, null, null, null)); m.addSerializer(Accounts.class, new RecurlyObjectsSerializer<Accounts, Account>(Accounts.class, "account")); m.addSerializer(AddOns.class, new RecurlyObjectsSerializer<AddOns, AddOn>(AddOns.class, "add_on")); m.addSerializer(Adjustments.class, new RecurlyObjectsSerializer<Adjustments, Adjustment>(Adjustments.class, "adjustment")); m.addSerializer(Coupons.class, new RecurlyObjectsSerializer<Coupons, Coupon>(Coupons.class, "coupon")); m.addSerializer(Invoices.class, new RecurlyObjectsSerializer<Invoices, Invoice>(Invoices.class, "invoice")); m.addSerializer(Plans.class, new RecurlyObjectsSerializer<Plans, Plan>(Plans.class, "plan")); m.addSerializer(RecurlyErrors.class, new RecurlyObjectsSerializer<RecurlyErrors, RecurlyError>(RecurlyErrors.class, "error")); m.addSerializer(SubscriptionAddOns.class, new RecurlyObjectsSerializer<SubscriptionAddOns, SubscriptionAddOn>(SubscriptionAddOns.class, "subscription_add_on")); m.addSerializer(Subscriptions.class, new RecurlyObjectsSerializer<Subscriptions, Subscription>(Subscriptions.class, "subscription")); m.addSerializer(Transactions.class, new RecurlyObjectsSerializer<Transactions, Transaction>(Transactions.class, "transaction")); xmlMapper.registerModule(m);// w w w .j a v a2 s.c om return xmlMapper; }
From source file:com.infinities.nova.util.jackson.JacksonProvider.java
public JacksonProvider() { AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); // if using BOTH JAXB annotations AND Jackson annotations: AnnotationIntrospector secondary = new JacksonAnnotationIntrospector(); ObjectMapper mapper = new ObjectMapper().registerModule(new Hibernate4Module()) .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")) .enable(SerializationFeature.INDENT_OUTPUT) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .setAnnotationIntrospector(new AnnotationIntrospectorPair(introspector, secondary)); NullStringSerializer serializer = new NullStringSerializer(); SimpleModule module = new SimpleModule("NullToNoneDeserializer"); module.addSerializer(String.class, serializer); mapper.registerModule(module);//from w ww .jav a2 s. com // mapper = mapper.setSerializationInclusion(Include) setMapper(mapper); }
From source file:com.infinities.nova.util.jackson.ObjectMapperResolver.java
public ObjectMapperResolver() { objectMapper = new ObjectMapper(); AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); AnnotationIntrospector secondary = new JacksonAnnotationIntrospector(); objectMapper = objectMapper//w w w. j a va2 s.com .setAnnotationIntrospector(new AnnotationIntrospectorPair(introspector, secondary)); objectMapper = objectMapper.enable(SerializationFeature.INDENT_OUTPUT); objectMapper = objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true); objectMapper.registerModule(new Hibernate4Module()); }
From source file:com.abiquo.bond.api.AbiquoObjectMapper.java
private AbiquoObjectMapper() { objectMapper = new ObjectMapper().setAnnotationIntrospector( // new AnnotationIntrospectorPair(new JacksonAnnotationIntrospector(), new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()))) // .registerModule(new AbiquoModule()); }
From source file:com.infinities.keystone4j.utils.jackson.ObjectMapperResolver.java
public ObjectMapperResolver() { objectMapper = new ObjectMapper(); AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); AnnotationIntrospector secondary = new JacksonAnnotationIntrospector(); objectMapper = objectMapper/*from w ww. j a v a2 s.co m*/ .setAnnotationIntrospector(new AnnotationIntrospectorPair(introspector, secondary)); objectMapper = objectMapper.enable(SerializationFeature.INDENT_OUTPUT); objectMapper.registerModule(new Hibernate4Module()); }
From source file:com.grl.tables.RowObjectSerializer.java
public RowObjectSerializer() { mapper = new ObjectMapper(); mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(new JacksonAnnotationIntrospector(), new JaxbAnnotationIntrospector(mapper.getTypeFactory()))); }
From source file:org.bremersee.common.jms.DefaultJmsConverter.java
/** * Default constructor./*from w w w . ja va2s. co m*/ */ public DefaultJmsConverter() { objectMapper = new ObjectMapper(); AnnotationIntrospector primary = new JacksonAnnotationIntrospector(); AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); AnnotationIntrospectorPair pair = new AnnotationIntrospectorPair(primary, secondary); objectMapper.setAnnotationIntrospector(pair); }
From source file:org.bremersee.common.web.client.ResponseErrorHandlerImpl.java
/** * Default constructor./*from ww w. j a v a 2s . co m*/ */ public ResponseErrorHandlerImpl() { Jaxb2Marshaller m = new Jaxb2Marshaller(); m.setContextPath(ThrowableMessageDto.class.getPackage().getName()); unmarshaller = m; objectMapper = new ObjectMapper(); // see http://wiki.fasterxml.com/JacksonJAXBAnnotations AnnotationIntrospector primary = new JacksonAnnotationIntrospector(); AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); AnnotationIntrospectorPair pair = new AnnotationIntrospectorPair(primary, secondary); objectMapper.setAnnotationIntrospector(pair); }
From source file:org.opencb.opencga.storage.hadoop.variant.converters.annotation.HBaseToVariantAnnotationConverter.java
public HBaseToVariantAnnotationConverter setReturnedFields(Set<VariantField> allReturnedFields) { List<String> list = new ArrayList<>(); if (allReturnedFields != null) { for (VariantField annotationField : VariantField.values()) { if (annotationField.getParent() == VariantField.ANNOTATION && !allReturnedFields.contains(annotationField)) { list.add(annotationField.fieldName().replace(VariantField.ANNOTATION.fieldName() + '.', "")); }//from w w w . j ava 2 s. c o m } } String[] returnedAnnotationFields = list.toArray(new String[list.size()]); objectMapper.setAnnotationIntrospector(new JacksonAnnotationIntrospector() { @Override public String[] findPropertiesToIgnore(Annotated ac, boolean forSerialization) { String[] propertiesToIgnore = super.findPropertiesToIgnore(ac, forSerialization); if (ArrayUtils.isNotEmpty(propertiesToIgnore)) { List<String> list = new ArrayList<>(); Collections.addAll(list, returnedAnnotationFields); Collections.addAll(list, propertiesToIgnore); return list.toArray(new String[list.size()]); } else { return returnedAnnotationFields; } } }); return this; }