Record Class GsonDocumentSend

java.lang.Object
java.lang.Record
eu.cloudnetservice.driver.impl.document.gson.send.GsonDocumentSend
Record Components:
rootElement - the root object element of the document send.
All Implemented Interfaces:
eu.cloudnetservice.driver.document.send.DocumentSend

public record GsonDocumentSend(@NonNull eu.cloudnetservice.driver.document.send.element.ObjectElement rootElement) extends Record implements eu.cloudnetservice.driver.document.send.DocumentSend
An implementation of a document send specifically made for gson.
Since:
4.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final @NonNull eu.cloudnetservice.driver.document.send.element.ObjectElement
    The field for the rootElement record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GsonDocumentSend(@NonNull eu.cloudnetservice.driver.document.send.element.ObjectElement rootElement)
    Creates an instance of a GsonDocumentSend record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    static @NonNull eu.cloudnetservice.driver.document.send.DocumentSend
    fromJsonObject(@NonNull com.google.gson.JsonObject object)
    Constructs a document send instance from the given gson json object.
    final int
    Returns a hash code value for this object.
    eu.cloudnetservice.driver.document.Document.Mutable
    into(@NonNull eu.cloudnetservice.driver.document.DocumentFactory factory)
    @NonNull eu.cloudnetservice.driver.document.send.element.ObjectElement
    Returns the value of the rootElement record component.
    private static @NonNull eu.cloudnetservice.driver.document.send.element.ArrayElement
    serializeArray(@NonNull String key, @NonNull com.google.gson.JsonArray array)
    Serialises the given gson json array into an array element.
    private static @NonNull eu.cloudnetservice.driver.document.send.element.ObjectElement
    serializeObject(@NonNull String key, @NonNull com.google.gson.JsonObject object)
    Serialises the given gson json object into an object element.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • rootElement

      @NonNull private final @NonNull eu.cloudnetservice.driver.document.send.element.ObjectElement rootElement
      The field for the rootElement record component.
  • Constructor Details

    • GsonDocumentSend

      public GsonDocumentSend(@NonNull @NonNull eu.cloudnetservice.driver.document.send.element.ObjectElement rootElement)
      Creates an instance of a GsonDocumentSend record class.
      Parameters:
      rootElement - the value for the rootElement record component
  • Method Details

    • fromJsonObject

      @NonNull public static @NonNull eu.cloudnetservice.driver.document.send.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 eu.cloudnetservice.driver.document.send.element.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 eu.cloudnetservice.driver.document.send.element.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

      @NonNull public eu.cloudnetservice.driver.document.Document.Mutable into(@NonNull @NonNull eu.cloudnetservice.driver.document.DocumentFactory factory)
      Specified by:
      into in interface eu.cloudnetservice.driver.document.send.DocumentSend
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • rootElement

      @NonNull public @NonNull eu.cloudnetservice.driver.document.send.element.ObjectElement rootElement()
      Returns the value of the rootElement record component.
      Specified by:
      rootElement in interface eu.cloudnetservice.driver.document.send.DocumentSend
      Returns:
      the value of the rootElement record component