All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.useful_solutions.tosamara_sdk.classifier.deserializer.NumberRoutesDeserializer Maven / Gradle / Ivy

There is a newer version: 1.5
Show newest version
package com.github.useful_solutions.tosamara_sdk.classifier.deserializer;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class NumberRoutesDeserializer extends JsonDeserializer> {

    @Override
    public List deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
        String value = jsonParser.getText();
        if (value != null && !value.isEmpty()) {
            return Arrays.asList(value
                    .replaceAll("\\s", "")
                    .split(","));
        } else {
            return Collections.emptyList();
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy