Package co.ecg.alpaca.core.framework
Class JSONUtils
java.lang.Object
co.ecg.alpaca.core.framework.JSONUtils
A utility class for JSON handling
- Version:
- $Id: $Id
- Author:
- Matthew Keathley on 4/4/16.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classA handler for serialization and deserialization of Optionals.static classDeserializer Class for SuperTypes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.gson.Gsonstatic com.google.gson.GsongetDeserializerGSON(boolean prettyPrint) static com.google.gson.GsongetDeserializerGSON(BroadWorksServer broadWorksServer) Retrieves a deserializer GSON object for standard deserialization of JSON to Alpaca Objectsstatic com.google.gson.GsongetDeserializerGSON(BroadWorksServer broadWorksServer, String sourceDefaultDomain, boolean isAdoptDestinationDefaultDomain) Retrieves a deserializer GSON object for standard deserialization of JSON to Alpaca Objectsstatic com.google.gson.GsonRetrieves a serializer GSON object for standard creation of JSON from Alpaca Objectsstatic <T extends BroadWorksObjectInformation>
TinputBroadWorksInformation(Type type, FileReader fileReader, BroadWorksServer broadWorksServer) Imports a BroadWorksObjectInformation class from the specified Filestatic <T extends BroadWorksObjectInformation>
voidoutputBroadWorksInformation(T information, FileWriter fileWriter) Outputs a BroadWorksObjectInformation class as JSON to the specified FileOutputStream
-
Constructor Details
-
JSONUtils
Constructor for JSONUtils.
- Parameters:
alpacaProperties- aAlpacaPropertiesobject.
-
-
Method Details
-
getSerializerGSON
public static com.google.gson.Gson getSerializerGSON()Retrieves a serializer GSON object for standard creation of JSON from Alpaca Objects- Returns:
- The GSON object
-
getDeserializerGSON
- Throws:
HelperException
-
getDeserializerGSON
- Throws:
HelperException
-
getDeserializerGSON
public static com.google.gson.Gson getDeserializerGSON(BroadWorksServer broadWorksServer, String sourceDefaultDomain, boolean isAdoptDestinationDefaultDomain) throws HelperException Retrieves a deserializer GSON object for standard deserialization of JSON to Alpaca Objects- Parameters:
broadWorksServer- The BroadWorksServer to deserialize into.sourceDefaultDomain- The SourceDefault domain if conversion is not expectedisAdoptDestinationDefaultDomain- Flag to adopt the deserialized information to the new default domain of the provided BroadWorksServer- Returns:
- The GSON object
- Throws:
HelperException- Thrown if the BroadWorksServer or SourceDefaultDomain is null
-
getDeserializerGSON
public static com.google.gson.Gson getDeserializerGSON(BroadWorksServer broadWorksServer) throws HelperException Retrieves a deserializer GSON object for standard deserialization of JSON to Alpaca Objects- Parameters:
broadWorksServer- The BroadWorksServer to deserialize into.- Returns:
- The GSON object
- Throws:
HelperException- if any.
-
outputBroadWorksInformation
public static <T extends BroadWorksObjectInformation> void outputBroadWorksInformation(T information, FileWriter fileWriter) throws HelperException Outputs a BroadWorksObjectInformation class as JSON to the specified FileOutputStream- Parameters:
information- The input informationfileWriter- The output stream for the generated JSON- Throws:
HelperException- Throw if an error occurs while outputting the information.
-
inputBroadWorksInformation
public static <T extends BroadWorksObjectInformation> T inputBroadWorksInformation(Type type, FileReader fileReader, BroadWorksServer broadWorksServer) throws HelperException Imports a BroadWorksObjectInformation class from the specified File- Parameters:
type- The Information typefileReader- The file reader for the JSON objectbroadWorksServer- The BroadWorksServer to deserialize into.- Returns:
- Returns a BroadWorksObjectInformation from the reader.
- Throws:
HelperException- Throw if an error occurs on input.
-