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

nl.vpro.domain.classification.bind.TermWrapperJsonString Maven / Gradle / Ivy

Go to download

The classes needed for the 'classification' service used in POMS. This os based on ClassificationScheme xml's as provided by EBU. It at the moment is only used for genres, but it could in principle accommodate other types of classification based on a fixed list.

There is a newer version: 8.3.0
Show newest version
package nl.vpro.domain.classification.bind;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
 * Used to let the terms list in the MediaObject json be just an array of strings (see MSE-1267)
 *
 * @author Michiel Meeuwissen
 */
public class TermWrapperJsonString {

    private TermWrapperJsonString() {
    }

    public static class Serializer extends JsonSerializer {
        @Override
        public void serialize(AbstractTermWrapper value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
            jgen.writeString(value.getName());
        }
    }

    public static abstract class Deserializer extends JsonDeserializer {
        @Override
        public T deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
            T wrapper = getTermWrapper();
            wrapper.setName(jp.getText());
            return wrapper;
        }
        protected abstract T getTermWrapper();

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy