Example usage for com.fasterxml.jackson.core Version unknownVersion

List of usage examples for com.fasterxml.jackson.core Version unknownVersion

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core Version unknownVersion.

Prototype

public static Version unknownVersion() 

Source Link

Document

Method returns canonical "not known" version, which is used as version in cases where actual version information is not known (instead of null).

Usage

From source file:com.basho.riak.client.api.commands.mapreduce.MapReduce.java

/**
 * Creates the JSON string of the M/R job for submitting to the client
 * <p/>/*from w  w w  . ja  v a2  s . c om*/
 * Uses Jackson to write out the JSON string. I'm not very happy with this method, it is a candidate for change.
 * <p/>
 * TODO re-evaluate this method, look for something smaller and more elegant.
 *
 * @return a String of JSON
 * @throws RiakException if, for some reason, we can't create a JSON string.
 */
String writeSpec() throws RiakException {

    final ByteArrayOutputStream out = new ByteArrayOutputStream();

    try {
        JsonGenerator jg = new JsonFactory().createGenerator(out, JsonEncoding.UTF8);

        ObjectMapper objectMapper = new ObjectMapper();
        SimpleModule specModule = new SimpleModule("SpecModule", Version.unknownVersion());
        specModule.addSerializer(LinkPhase.class, new LinkPhaseSerializer());
        specModule.addSerializer(FunctionPhase.class, new FunctionPhaseSerializer());
        specModule.addSerializer(BucketInput.class, new BucketInputSerializer());
        specModule.addSerializer(SearchInput.class, new SearchInputSerializer());
        specModule.addSerializer(BucketKeyInput.class, new BucketKeyInputSerializer());
        specModule.addSerializer(IndexInput.class, new IndexInputSerializer());
        objectMapper.registerModule(specModule);

        jg.setCodec(objectMapper);

        List<MapReducePhase> phases = spec.getPhases();
        phases.get(phases.size() - 1).setKeep(true);
        jg.writeObject(spec);

        jg.flush();

        return out.toString("UTF8");

    } catch (IOException e) {
        throw new RiakException(e);
    }
}

From source file:org.osiam.client.AbstractOsiamService.java

protected AbstractOsiamService(Builder<T> builder) {
    type = builder.type;//from   w w w . ja va2s . c o m
    typeName = builder.typeName;
    endpoint = builder.endpoint;

    mapper = new ObjectMapper();
    SimpleModule userDeserializerModule = new SimpleModule("userDeserializerModule", Version.unknownVersion())
            .addDeserializer(User.class, new UserDeserializer(User.class));
    mapper.registerModule(userDeserializerModule);

    targetEndpoint = client.target(endpoint);
}

From source file:com.logsniffer.app.CoreAppConfig.java

@Bean
public ObjectMapper jsonObjectMapper() {
    final ObjectMapper jsonMapper = new ObjectMapper();
    jsonMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    jsonMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    jsonMapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
    jsonMapper.configure(Feature.ALLOW_SINGLE_QUOTES, true);
    jsonMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false);

    final SimpleModule module = new SimpleModule("FieldsMapping", Version.unknownVersion());
    module.setSerializerModifier(new BeanSerializerModifier() {
        @Override/*from   w  ww  .jav a2  s  .c  o m*/
        public JsonSerializer<?> modifyMapSerializer(final SerializationConfig config, final MapType valueType,
                final BeanDescription beanDesc, final JsonSerializer<?> serializer) {
            if (FieldsMap.class.isAssignableFrom(valueType.getRawClass())) {
                return new FieldsMapMixInLikeSerializer();
            } else {
                return super.modifyMapSerializer(config, valueType, beanDesc, serializer);
            }
        }
    });
    jsonMapper.registerModule(module);
    return jsonMapper;
}

From source file:com.proofpoint.event.collector.TestFilteringMapSerializer.java

private ObjectMapper getMapper(FilteringMapSerializer filteringMapSerializer) {
    SimpleModule testModule = new SimpleModule("FilteringEventModule", Version.unknownVersion());
    testModule.addSerializer(filteringMapSerializer);
    ObjectMapper mapper = new ObjectMapperProvider().get();
    mapper.registerModule(testModule);//from w w  w  .  ja  v a 2s. c o m
    return mapper;
}

From source file:com.zenesis.qx.remote.ProxyObjectMapper.java

/**
 * Constructor/*  w w w .  ja v  a 2s . c o m*/
 * @param tracker
 * @param indent whether to indent JSON
 * @param rootDir root directory to serialise all File's as relative to
 */
public ProxyObjectMapper(ProxySessionTracker tracker, boolean indent, File rootDir) {
    super();
    this.tracker = tracker;
    SimpleModule module = new SimpleModule("ProxyObjectMapper", Version.unknownVersion());
    module.addSerializer(Proxied.class, new ProxiedSerializer());
    module.addDeserializer(Proxied.class, new ProxiedDeserializer());
    module.addSerializer(Date.class, new DateSerializer());
    module.addSerializer(String.class, new StringSerializer());
    module.addSerializer(Enum.class, new EnumSerializer());
    module.addSerializer(File.class, new FileSerializer(rootDir));
    module.addDeserializer(File.class, new FileDeserializer(rootDir));
    module.addSerializer(Map.class, new MapSerializer());
    registerModule(module);
}

From source file:org.springframework.cloud.dataflow.server.stream.SkipperStreamDeployer.java

public static List<AppStatus> deserializeAppStatus(String platformStatus) {
    try {//from www. j a v a 2 s .  c  o m
        if (platformStatus != null) {
            ObjectMapper mapper = new ObjectMapper();
            mapper.addMixIn(AppStatus.class, AppStatusMixin.class);
            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
            SimpleModule module = new SimpleModule("CustomModel", Version.unknownVersion());
            SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
            resolver.addMapping(AppInstanceStatus.class, AppInstanceStatusImpl.class);
            module.setAbstractTypes(resolver);
            mapper.registerModule(module);
            TypeReference<List<AppStatus>> typeRef = new TypeReference<List<AppStatus>>() {
            };
            return mapper.readValue(platformStatus, typeRef);
        }
        return new ArrayList<AppStatus>();
    } catch (Exception e) {
        logger.error("Could not parse Skipper Platform Status JSON [" + platformStatus + "]. "
                + "Exception message = " + e.getMessage());
        return new ArrayList<AppStatus>();
    }
}