com.github.useful_solutions.tosamara_sdk.classifier.deserializer.InfotabloDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tosamara-sdk Show documentation
Show all versions of tosamara-sdk Show documentation
SDK for working with API of tosamara.ru on Java
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.Optional;
public class InfotabloDeserializer extends JsonDeserializer {
@Override
public Boolean deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
String value = jsonParser.getText();
return Optional.ofNullable(value)
.map(s -> !s.equals("нет"))
.orElse(null);
}
}