001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     matic
011 */
012package org.nuxeo.ecm.automation.client.jaxrs.spi;
013
014import java.io.IOException;
015
016import org.codehaus.jackson.JsonGenerator;
017import org.codehaus.jackson.JsonParser;
018
019/**
020 * Plugs in automation client new input/output marshalling logic.
021 *
022 * @author matic
023 * @param <T>
024 */
025public interface JsonMarshaller<T> {
026
027    /**
028     * The type name that appears in serialization
029     *
030     * @return
031     */
032    String getType();
033
034    /**
035     * The marshalled java type
036     *
037     * @return
038     */
039    Class<T> getJavaType();
040
041    /**
042     * Builds and returns a POJO from the JSON object
043     *
044     * @param json
045     * @return
046     */
047    T read(JsonParser jp) throws IOException;
048
049    /**
050     * Writes the POJO object to the JsonGenerator
051     *
052     * @param o
053     * @param value
054     */
055    void write(JsonGenerator jg, Object value) throws IOException;
056
057}