001/*
002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nicolas Chapurlat <nchapurlat@nuxeo.com>
016 */
017
018package org.nuxeo.ecm.core.io.registry;
019
020import java.io.IOException;
021import java.io.InputStream;
022import java.lang.reflect.Type;
023
024import javax.ws.rs.core.MediaType;
025
026/**
027 * Interface of mimetype to Java type converter.
028 * <p>
029 * see {@link Marshaller} for more details.
030 * </p>
031 *
032 * @param <EntityType> The managed Java type.
033 * @since 7.2
034 */
035public interface Reader<EntityType> extends Marshaller<EntityType> {
036
037    /**
038     * Read the entity from in {@link InputStream} using mediatype format.
039     * <p>
040     * This method implementation can use injected properties.
041     * </p>
042     *
043     * @param clazz The requested marshalled class.
044     * @param genericType The requested marshalled generic type.
045     * @param mediatype The input mediatype.
046     * @param in The input of this marshaller.
047     * @throws IOException If some error append while reading entity from in.
048     * @since 7.2
049     */
050    EntityType read(Class<?> clazz, Type genericType, MediaType mediaType, InputStream in) throws IOException;
051
052}