Record Class XmlComponent

java.lang.Object
java.lang.Record
io.github.toberocat.guiengine.xml.XmlComponent

public record XmlComponent(@NotNull Map<String,com.fasterxml.jackson.databind.JsonNode> fields, @NotNull RenderPriority renderPriority, @NotNull String type, @NotNull String id) extends Record
Represents an XML component to be deserialized from JSON using Jackson. This class defines a record to store data for an XML component. It is annotated with JsonDeserialize to use the ComponentDeserializer for deserialization.

Created: 04/02/2023 Author: Tobias Madlberger (Tobias)

  • Constructor Summary

    Constructors
    Constructor
    Description
    XmlComponent(@NotNull Map<String,com.fasterxml.jackson.databind.JsonNode> fields, @NotNull RenderPriority renderPriority, @NotNull String type, @NotNull String id)
    Creates an instance of a XmlComponent record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    @NotNull Map<String,com.fasterxml.jackson.databind.JsonNode>
    Returns the value of the fields record component.
    final int
    Returns a hash code value for this object.
    @NotNull String
    id()
    Returns the value of the id record component.
    @NotNull Map<String,Object>
    objectFields(@NotNull GuiEngineApi api, @NotNull Function<com.fasterxml.jackson.databind.JsonNode,com.fasterxml.jackson.databind.JsonNode> transformer)
    Convert the fields of this to a map of objects.
    Returns the value of the renderPriority record component.
    final String
    Returns a string representation of this record class.
    @NotNull String
    Returns the value of the type record component.

    Methods inherited from class java.lang.Object

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

    • XmlComponent

      public XmlComponent(@NotNull @NotNull Map<String,com.fasterxml.jackson.databind.JsonNode> fields, @NotNull @NotNull RenderPriority renderPriority, @NotNull @NotNull String type, @NotNull @NotNull String id)
      Creates an instance of a XmlComponent record class.
      Parameters:
      fields - the value for the fields record component
      renderPriority - the value for the renderPriority record component
      type - the value for the type record component
      id - the value for the id record component
  • Method Details

    • objectFields

      @NotNull public @NotNull Map<String,Object> objectFields(@NotNull @NotNull GuiEngineApi api, @NotNull @NotNull Function<com.fasterxml.jackson.databind.JsonNode,com.fasterxml.jackson.databind.JsonNode> transformer)
      Convert the fields of this to a map of objects. This method is used to transform the stored JSON data to a map of objects, where each field's value is converted to its corresponding Java object representation. The method also adds additional properties like "id", "type", and "renderPriority" to the map.
      Parameters:
      api - The GuiEngineApi instance to use for object conversion.
      transformer - The Function to apply to each JSON value before conversion to an object.
      Returns:
      A map containing the fields of this as Java objects, including additional properties.
    • 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.
    • fields

      @NotNull public @NotNull Map<String,com.fasterxml.jackson.databind.JsonNode> fields()
      Returns the value of the fields record component.
      Returns:
      the value of the fields record component
    • renderPriority

      @NotNull public @NotNull RenderPriority renderPriority()
      Returns the value of the renderPriority record component.
      Returns:
      the value of the renderPriority record component
    • type

      @NotNull public @NotNull String type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • id

      @NotNull public @NotNull String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component