Record Class GsonDocumentSend
java.lang.Object
java.lang.Record
eu.cloudnetservice.driver.document.gson.send.GsonDocumentSend
- Record Components:
rootElement- the root object element of the document send.
- All Implemented Interfaces:
DocumentSend
public record GsonDocumentSend(@NonNull ObjectElement rootElement)
extends Record
implements DocumentSend
An implementation of a document send specifically made for gson.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final @NonNull ObjectElementThe field for therootElementrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionGsonDocumentSend(@NonNull ObjectElement rootElement) Creates an instance of aGsonDocumentSendrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static @NonNull DocumentSendfromJsonObject(@NonNull com.google.gson.JsonObject object) Constructs a document send instance from the given gson json object.final inthashCode()Returns a hash code value for this object.into(@NonNull DocumentFactory factory) Receives this document into the given document factory.Returns the value of therootElementrecord component.private static @NonNull ArrayElementserializeArray(@NonNull String key, @NonNull com.google.gson.JsonArray array) Serialises the given gson json array into an array element.private static @NonNull ObjectElementserializeObject(@NonNull String key, @NonNull com.google.gson.JsonObject object) Serialises the given gson json object into an object element.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
rootElement
The field for therootElementrecord component.
-
-
Constructor Details
-
GsonDocumentSend
Creates an instance of aGsonDocumentSendrecord class.- Parameters:
rootElement- the value for therootElementrecord component
-
-
Method Details
-
fromJsonObject
@NonNull public static @NonNull DocumentSend fromJsonObject(@NonNull @NonNull com.google.gson.JsonObject object) Constructs a document send instance from the given gson json object.- Parameters:
object- the json object to construct the document send from.- Returns:
- the document send constructed from the given json object.
- Throws:
NullPointerException- if the given json object is null.
-
serializeObject
@NonNull private static @NonNull ObjectElement serializeObject(@NonNull @NonNull String key, @NonNull @NonNull com.google.gson.JsonObject object) Serialises the given gson json object into an object element.- Parameters:
key- the key of the given json object.object- the object to serialize.- Returns:
- an object element serialized from the given gson json object.
- Throws:
NullPointerException- if the given key or json object is null.
-
serializeArray
@NonNull private static @NonNull ArrayElement serializeArray(@NonNull @NonNull String key, @NonNull @NonNull com.google.gson.JsonArray array) Serialises the given gson json array into an array element.- Parameters:
key- the key of the given json array.array- the array to serialize.- Returns:
- an array element serialized from the given gson json array.
- Throws:
NullPointerException- if the given key or json array is null.
-
into
Receives this document into the given document factory. In normal cases the given document factory should create a new, empty document and import all supported key-value pairs that are supplied by this send into it.The receiving process of a document send should never throw an exception unless the given document send contains malformed or invalid data making it impossible to get imported.
- Specified by:
intoin interfaceDocumentSend- Parameters:
factory- the document factory that is supposed to receive this document send.- Returns:
- a new, empty document containing all supported key-value pairs of the given document send.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
rootElement
Returns the value of therootElementrecord component.- Specified by:
rootElementin interfaceDocumentSend- Returns:
- the value of the
rootElementrecord component
-