Example usage for com.fasterxml.jackson.databind DeserializationFeature enabledByDefault

List of usage examples for com.fasterxml.jackson.databind DeserializationFeature enabledByDefault

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind DeserializationFeature enabledByDefault.

Prototype

public boolean enabledByDefault() 

Source Link

Usage

From source file:org.jberet.support.io.MappingJsonFactoryObjectFactory.java

static void configureDeserializationFeatures(final ObjectMapper objectMapper, final String features) {
    final StringTokenizer st = new StringTokenizer(features, ",");
    while (st.hasMoreTokens()) {
        final String[] pair = NoMappingJsonFactoryObjectFactory.parseSingleFeatureValue(st.nextToken().trim());
        final String key = pair[0];
        final String value = pair[1];

        final DeserializationFeature feature;
        try {/*from www.  j av  a 2s  . c o m*/
            feature = DeserializationFeature.valueOf(key);
        } catch (final Exception e1) {
            throw SupportMessages.MESSAGES.unrecognizedReaderWriterProperty(key, value);
        }
        if ("true".equals(value)) {
            if (!feature.enabledByDefault()) {
                objectMapper.configure(feature, true);
            }
        } else if ("false".equals(value)) {
            if (feature.enabledByDefault()) {
                objectMapper.configure(feature, false);
            }
        } else {
            throw SupportMessages.MESSAGES.invalidReaderWriterProperty(null, value, key);
        }
    }
}