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

com.balajeetm.mystique.util.json.convertor.JsonConvertor Maven / Gradle / Ivy

/*
 * Copyright (c) Balajee TM 2016.
 * All rights reserved.
 * License -  @see 
 */

/*
 * Created on 25 Aug, 2016 by balajeetm
 * http://www.balajeetm.com
 */
package com.balajeetm.mystique.util.json.convertor;

import java.io.InputStream;
import java.util.List;

import com.balajeetm.mystique.util.json.error.ConvertorException;

/**
 * The Interface JsonConvertor.
 *
 * @author balajeetm
 */
public interface JsonConvertor {

	/**
	 * Deserialize a json input string to Java POJO.
	 *
	 * @param  the generic type of the Java POJO to be deserialized to
	 * @param jsonString the json input string
	 * @param pojoType the java pojo class
	 * @return the deserialized Java POJO
	 * @throws ConvertorException the convertor exception on any failures during
	 *             conversion
	 */
	 T deserialize(String jsonString, Class pojoType) throws ConvertorException;

	/**
	 * Deserialize a Java object to another Java POJO.
	 *
	 * @param  the generic type of the Java POJO to be deserialized to
	 * @param object the java object to be deserialized
	 * @param pojoType the java pojo class
	 * @return the deserialized Java POJO
	 * @throws ConvertorException the convertor exception on any failures during
	 *             conversion
	 */
	 T deserialize(Object object, Class pojoType) throws ConvertorException;

	/**
	 * Deserialize a json input stream to Java POJO.
	 * 
	 * @param  the generic type of the Java POJO to be deserialized to
	 * @param inputStream the json input stream
	 * @param pojoType the java pojo class
	 * @return the deserialized Java POJO
	 * @throws ConvertorException the convertor exception on any failures during
	 *             conversion
	 */
	 T deserialize(InputStream inputStream, Class pojoType) throws ConvertorException;

	/**
	 * Serialize.
	 * 
	 * @param pojo the Java POJO to be serialized
	 * @return the json string
	 * @throws ConvertorException the convertor exception on any failures during
	 *             conversion
	 */
	String serialize(Object pojo) throws ConvertorException;

	/**
	 * Deserialize a json string to a Java POJO group.
	 *
	 * @param  the generic Java group type to be deserialized to
	 * @param jsonString the json string
	 * @param groupClass the java group class
	 * @param pojoType the java pojo class
	 * @return the deserialized group of java POJOs
	 * @throws ConvertorException the convertor exception on any failures during
	 *             conversion
	 */
	 T deserializeGroup(String jsonString, Class groupClass, Class pojoType) throws ConvertorException;

	/**
	 * Deserialize a json input stream to a Java POJO group.
	 * 
	 * @param  the generic Java group type to be deserialized to
	 * @param inputStream the json input stream
	 * @param groupClass the java group class
	 * @param pojoType the java pojo class
	 * @return the deserialized group of java POJOs
	 * @throws ConvertorException the convertor exception on any failures during
	 *             conversion
	 */
	 T deserializeGroup(InputStream inputStream, Class groupClass, Class pojoType) throws ConvertorException;

	/**
	 * Deserialize a json input stream to a Java POJO list.
	 *
	 * @param  the generic type
	 * @param inputStream the json input stream
	 * @param pojoType the java pojo class
	 * @return the deserialized list of java POJOs
	 * @throws ConvertorException the convertor exception on any failures during
	 *             conversion
	 */
	 List deserializeList(InputStream inputStream, Class pojoType) throws ConvertorException;

	/**
	 * Deserialize a json string to a Java POJO list.
	 *
	 * @param  the generic Java group type to be deserialized to
	 * @param jsonString the json string
	 * @param pojoType the java pojo class
	 * @return the deserialized list of java POJOs
	 * @throws ConvertorException the convertor exception on any failures during
	 *             conversion
	 */
	 List deserializeList(String jsonString, Class pojoType) throws ConvertorException;

	/**
	 * Deserialize list.
	 *
	 * @param  the generic Java group type to be deserialized to
	 * @param object the Java object group to be serialized
	 * @param pojoType the java pojo class
	 * @return the deserialized list of java POJOs
	 * @throws ConvertorException the convertor exception on any failures during
	 *             conversion
	 */
	 List deserializeList(Object object, Class pojoType) throws ConvertorException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy