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

com.ibm.watson.developer_cloud.util.GsonSingleton Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
package com.ibm.watson.developer_cloud.util;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * The Class GsonSingleton.
 */
public class GsonSingleton {

	/** The gson. */
	private static Gson gson;
	
	/**
	 * Gets the gson.
	 *
	 * @return the gson
	 */
	public static Gson getGson() {
		if (gson == null) {
			gson = createGson();
		}
		return gson;
	}

	/**
	 * Creates a {@link com.google.gson.Gson} object that can be use to serialize 
	 * and deserialize Java objects}
	 *
	 * @return the gson
	 */
	private static Gson createGson() {
		return new GsonBuilder()
			.setPrettyPrinting()
			.create();
	};
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy