Class GsonResourceCodec<R>
java.lang.Object
com.inductiveautomation.ignition.gateway.config.GsonResourceCodec<R>
- All Implemented Interfaces:
JsonResourceCodec<R>,ResourceCodec<R>
A ResourceCodec that uses a Gson instance to directly encode and decode resources.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.inductiveautomation.ignition.common.gson.Gsonprotected final ResourceValidator<R> -
Constructor Summary
ConstructorsConstructorDescriptionGsonResourceCodec(Class<R> recordType, com.inductiveautomation.ignition.common.gson.Gson gson) GsonResourceCodec(Class<R> recordType, com.inductiveautomation.ignition.common.gson.Gson gson, ResourceValidator<R> validator) -
Method Summary
Modifier and TypeMethodDescriptionstatic <R> GsonResourceCodec<R>create(Class<R> recordType, Consumer<com.inductiveautomation.ignition.common.gson.GsonBuilder> gsonBuilderCustomizer) decodeFromJson(com.inductiveautomation.ignition.common.gson.JsonElement json) Similar toJsonResourceCodec.decode(Resource), but decodes the resource's config from a JSON element.decodeFromJson(Reader reader) Similar toJsonResourceCodec.decode(Resource), but reads the resource's config from a reader which will contain the JSON data of the encoded config object.voidencode(R config, ResourceBuilder builder) Encodes a resource's config object, and stores it in the resource in the appropriate location.com.inductiveautomation.ignition.common.gson.JsonElementencodeToJson(R resource) Converts a resource config object instance to a JSON representation.protected RMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.inductiveautomation.ignition.gateway.config.JsonResourceCodec
decodeMethods inherited from interface com.inductiveautomation.ignition.gateway.config.ResourceCodec
decodeIfValid
-
Field Details
-
recordType
-
gson
protected final com.inductiveautomation.ignition.common.gson.Gson gson -
validator
-
-
Constructor Details
-
GsonResourceCodec
-
GsonResourceCodec
public GsonResourceCodec(Class<R> recordType, com.inductiveautomation.ignition.common.gson.Gson gson, @Nullable ResourceValidator<R> validator)
-
-
Method Details
-
encode
Description copied from interface:ResourceCodecEncodes a resource's config object, and stores it in the resource in the appropriate location.- Specified by:
encodein interfaceResourceCodec<R>
-
encodeToJson
Description copied from interface:JsonResourceCodecConverts a resource config object instance to a JSON representation.- Specified by:
encodeToJsonin interfaceJsonResourceCodec<R>- Parameters:
resource- The resource to convert.- Returns:
- A JSON representation of the resource.
-
decodeFromJson
Description copied from interface:JsonResourceCodecSimilar toJsonResourceCodec.decode(Resource), but reads the resource's config from a reader which will contain the JSON data of the encoded config object.- Specified by:
decodeFromJsonin interfaceJsonResourceCodec<R>- Throws:
DecodingException
-
decodeFromJson
public R decodeFromJson(com.inductiveautomation.ignition.common.gson.JsonElement json) throws DecodingException Description copied from interface:JsonResourceCodecSimilar toJsonResourceCodec.decode(Resource), but decodes the resource's config from a JSON element.- Specified by:
decodeFromJsonin interfaceJsonResourceCodec<R>- Throws:
DecodingException
-
validate
- Throws:
ValidationException
-
create
public static <R> GsonResourceCodec<R> create(Class<R> recordType, @Nullable Consumer<com.inductiveautomation.ignition.common.gson.GsonBuilder> gsonBuilderCustomizer)
-