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

nl.renarj.jasdb.rest.serializers.json.JsonRestHandlerFactory Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
package nl.renarj.jasdb.rest.serializers.json;

import nl.renarj.jasdb.rest.model.RestEntity;
import nl.renarj.jasdb.rest.model.streaming.StreamableEntityCollection;
import nl.renarj.jasdb.rest.model.streaming.StreamedEntity;
import nl.renarj.jasdb.rest.serializers.RestResponseHandler;
import nl.renarj.jasdb.rest.serializers.json.entity.EntityHandler;
import nl.renarj.jasdb.rest.serializers.json.entity.EntityStreamCollectionHandler;

/**
 * @author Renze de Vries
 */
public class JsonRestHandlerFactory {
    private static final RestResponseHandler objectMapperHandler = new JsonRestObjectMapperHandler();
    private static final EntityStreamCollectionHandler entityStreamHandler = new EntityStreamCollectionHandler();
    private static final EntityHandler entityHandler = new EntityHandler();

    private JsonRestHandlerFactory() {

    }

    public static RestResponseHandler getRestResponseHandler(Class restEntity) {
        if(restEntity.equals(StreamableEntityCollection.class)) {
            return entityStreamHandler;
        } else if(restEntity.equals(StreamedEntity.class)) {
            return entityHandler;
        } else {
            return objectMapperHandler;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy