Example usage for com.fasterxml.jackson.databind.introspect AnnotationIntrospectorPair AnnotationIntrospectorPair

List of usage examples for com.fasterxml.jackson.databind.introspect AnnotationIntrospectorPair AnnotationIntrospectorPair

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.introspect AnnotationIntrospectorPair AnnotationIntrospectorPair.

Prototype

public AnnotationIntrospectorPair(AnnotationIntrospector p, AnnotationIntrospector s) 

Source Link

Usage

From source file:com.arpnetworking.clusteraggregator.configuration.EmitterConfiguration.java

/**
 * Create an <code>ObjectMapper</code> for Emitter configuration.
 *
 * @param injector The Guice <code>Injector</code> instance.
 * @return An <code>ObjectMapper</code> for Pipeline configuration.
 *//*from  ww w  . j  av a  2  s  .  co  m*/
public static ObjectMapper createObjectMapper(final Injector injector) {
    final ObjectMapper objectMapper = ObjectMapperFactory.createInstance();

    final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector();
    objectMapper.setInjectableValues(new GuiceInjectableValues(injector));
    objectMapper.setAnnotationIntrospectors(
            new AnnotationIntrospectorPair(guiceIntrospector,
                    objectMapper.getSerializationConfig().getAnnotationIntrospector()),
            new AnnotationIntrospectorPair(guiceIntrospector,
                    objectMapper.getDeserializationConfig().getAnnotationIntrospector()));

    return objectMapper;
}

From source file:org.jongo.marshall.jackson.configuration.AnnotationModifier.java

public void modify(ObjectMapper mapper) {
    AnnotationIntrospector jongoIntrospector = new JongoAnnotationIntrospector();
    AnnotationIntrospector defaultIntrospector = mapper.getSerializationConfig().getAnnotationIntrospector();
    AnnotationIntrospector pair = new AnnotationIntrospectorPair(jongoIntrospector, defaultIntrospector);

    mapper.setAnnotationIntrospector(pair);
}

From source file:ru.anr.base.services.serializer.JSONSerializerImpl.java

/**
 * Constructor. We can use both JAXB and Jackson annotations for mapping.
 *///  ww  w . j  a  va  2  s .  c om
public JSONSerializerImpl() {

    super(new ObjectMapper());

    // mapper().configure(SerializationFeature.WRAP_ROOT_VALUE, true);
    // mapper().configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);

    AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(mapper().getTypeFactory());
    AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();

    mapper().setAnnotationIntrospector(new AnnotationIntrospectorPair(introspector, secondary));
}

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.grl.tables.RowObjectSerializer.java

public RowObjectSerializer() {
    mapper = new ObjectMapper();
    mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(new JacksonAnnotationIntrospector(),
            new JaxbAnnotationIntrospector(mapper.getTypeFactory())));
}

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);/* www. j  av  a  2 s.  co  m*/

    return xmlMapper;
}

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//from  w ww . jav a  2s. c  om
            .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.infinities.keystone4j.utils.jackson.ObjectMapperResolver.java

public ObjectMapperResolver() {
    objectMapper = new ObjectMapper();
    AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
    AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
    objectMapper = objectMapper/*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.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);//  ww w.jav a  2s . c  om
}

From source file:com.arpnetworking.metrics.mad.configuration.PipelineConfiguration.java

/**
 * Create an <code>ObjectMapper</code> for Pipeline configuration.
 *
 * @param injector The Guice <code>Injector</code> instance.
 * @return An <code>ObjectMapper</code> for Pipeline configuration.
 *//*from  w w  w. j  av  a2s.com*/
public static ObjectMapper createObjectMapper(final Injector injector) {
    final ObjectMapper objectMapper = ObjectMapperFactory.createInstance();

    final SimpleModule module = new SimpleModule("Pipeline");
    module.addDeserializer(Statistic.class, new StatisticDeserializer());

    objectMapper.registerModules(module);

    final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector();
    objectMapper.setInjectableValues(new GuiceInjectableValues(injector));
    objectMapper.setAnnotationIntrospectors(
            new AnnotationIntrospectorPair(guiceIntrospector,
                    objectMapper.getSerializationConfig().getAnnotationIntrospector()),
            new AnnotationIntrospectorPair(guiceIntrospector,
                    objectMapper.getDeserializationConfig().getAnnotationIntrospector()));

    return objectMapper;
}