Example usage for com.fasterxml.jackson.datatype.joda JodaModule JodaModule

List of usage examples for com.fasterxml.jackson.datatype.joda JodaModule JodaModule

Introduction

In this page you can find the example usage for com.fasterxml.jackson.datatype.joda JodaModule JodaModule.

Prototype

public JodaModule() 

Source Link

Usage

From source file:com.twentyn.bioreactor.pH.ControlSystem.java

public static void main(String[] args) throws Exception {

    Options opts = new Options();
    for (Option.Builder b : OPTION_BUILDERS) {
        opts.addOption(b.build());/*from www .  j  a va 2s .c  om*/
    }

    CommandLine cl = null;
    try {
        CommandLineParser parser = new DefaultParser();
        cl = parser.parse(opts, args);
    } catch (ParseException e) {
        LOGGER.error(String.format("Argument parsing failed: %s\n", e.getMessage()));
        HELP_FORMATTER.printHelp(ControlSystem.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        System.exit(1);
    }

    if (cl.hasOption("help")) {
        HELP_FORMATTER.printHelp(ControlSystem.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        return;
    }

    SOLUTION solution = null;
    String acidOrBase = cl.getOptionValue(OPTION_CONTROL_SOLUTION);

    if (acidOrBase.equals(SOLUTION.ACID.name())) {
        solution = SOLUTION.ACID;
    }

    if (acidOrBase.equals(SOLUTION.BASE.name())) {
        solution = SOLUTION.BASE;
    }

    if (solution == null) {
        LOGGER.error("Input solution is neither %s or %s", SOLUTION.ACID.name(), SOLUTION.BASE.name());
        return;
    }

    Double targetPH = Double.parseDouble(cl.getOptionValue(OPTION_TARGET_PH));

    File sensorReadingDataFile = new File(
            cl.getOptionValue(OPTION_SENSOR_READING_FILE_LOCATION, SENSOR_READING_FILE_LOCATION));

    MotorPinConfiguration motorPinConfiguration = new MotorPinConfiguration(
            MotorPinConfiguration.PinNumberingScheme.BOARD);
    motorPinConfiguration.initializeGPIOPinsAndSetConfigToStartState();

    ControlSystem controlSystem = new ControlSystem(motorPinConfiguration, solution, targetPH,
            sensorReadingDataFile);
    controlSystem.registerModuleForObjectMapper(new JodaModule());
    try {
        controlSystem.run();
    } finally {
        LOGGER.info("Shutting down");
        controlSystem.shutdownFermentation();
    }
}

From source file:org.lable.rfc3881.auditlogger.serialization.ObjectMapperFactory.java

/**
 * Configures an {@link ObjectMapper} instance with the serialization strategies needed for this project.
 *
 * @return An object-mapper.//  w  w w  . ja  v  a  2  s.  c  om
 */
public static ObjectMapper getObjectMapper() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new RFC3881Module());
    objectMapper.registerModule(new JodaModule());
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);

    return objectMapper;
}

From source file:de.taimos.dvalin.jaxrs.MapperFactory.java

public static ObjectMapper createDefault() {
    ObjectMapper m = new ObjectMapper();
    m.registerModule(new JodaModule());
    m.registerModule(new GuavaModule());
    m.setSerializationInclusion(Include.NON_NULL);
    m.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
    m.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    m.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
    m.enable(MapperFeature.AUTO_DETECT_GETTERS);
    return m;/*  ww w.  j a v  a  2  s  .  c o  m*/
}

From source file:org.obiba.mica.web.rest.TestUtil.java

/**
 * Convert an object to JSON byte array.
 *
 * @param object the object to convert/*from  w w  w. j a  va  2s .co  m*/
 * @return the JSON byte array
 * @throws IOException
 */
public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JodaModule());
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    return mapper.writeValueAsBytes(object);
}

From source file:de.cinovo.cloudconductor.api.lib.helper.MapperFactory.java

/**
 * @return the object mapper/*from  w w w .java  2  s .c  om*/
 */
public static ObjectMapper createDefault() {
    ObjectMapper m = new ObjectMapper();
    m.registerModule(new JodaModule());
    m.registerModule(new GuavaModule());
    m.setSerializationInclusion(Include.NON_NULL);
    m.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
    m.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    m.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
    m.enable(MapperFeature.AUTO_DETECT_GETTERS);
    return m;
}

From source file:org.mythtv.services.api.JacksonUtils.java

public static ObjectMapper initObjectMapper() {
    StdDelegatingDeserializer<ArrayOfString> delegatingDeserializer = new StdDelegatingDeserializer<ArrayOfString>(
            new ArrayOfStringConverter());
    SimpleModule customModule = new SimpleModule("org.mythtv.services.api.module",
            new Version(1, 0, 0, null, null, null)).addDeserializer(ArrayOfString.class,
                    delegatingDeserializer);

    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JodaModule());
    objectMapper.registerModule(customModule);
    objectMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
    return objectMapper;
}

From source file:com.microsoft.rest.serializer.JacksonHelper.java

/**
 * Gets a static instance of {@link ObjectMapper}.
 *
 * @return an instance of {@link ObjectMapper}.
 *///w w w.  j a  va  2s  . com
public static ObjectMapper getObjectMapper() {
    if (objectMapper == null) {
        objectMapper = new ObjectMapper().configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
                .configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true)
                .setSerializationInclusion(JsonInclude.Include.NON_NULL).registerModule(new JodaModule())
                .registerModule(ByteArraySerializer.getModule()).registerModule(DateTimeSerializer.getModule())
                .registerModule(DateTimeRfc1123Serializer.getModule());
    }
    return objectMapper;
}

From source file:com.hp.autonomy.types.idol.content.ScheduleTest.java

@Test
public void json() throws IOException {
    final ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JodaModule());
    final byte[] json = objectMapper.writeValueAsBytes(schedule);
    assertNotNull(json);/*from  w  w  w.ja v  a 2  s . c o m*/
    final Schedule processedSchedule = objectMapper.readValue(json, Schedule.class);
    assertEquals(schedule, processedSchedule);
}

From source file:com.arpnetworking.jackson.ObjectMapperFactory.java

private static ObjectMapper createModifiableObjectMapper(final String name) {
    final ObjectMapper objectMapper = new ObjectMapper();
    final SimpleModule module = new SimpleModule(name);
    module.addSerializer(Optional.class, OptionalSerializer.newInstance());
    objectMapper.registerModule(module);
    objectMapper.registerModule(new JodaModule());
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(DeserializationFeature.WRAP_EXCEPTIONS, false);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    return objectMapper;
}

From source file:com.ning.metrics.collector.guice.providers.CollectorObjectMapperProvider.java

@Override
public ObjectMapper get() {
    final ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
    mapper.registerModule(new JodaModule());
    mapper.registerModule(new GuavaModule());
    return mapper;
}