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
ConstructorsConstructorDescriptionXmlComponent(@NotNull Map<String, com.fasterxml.jackson.databind.JsonNode> fields, @NotNull RenderPriority renderPriority, @NotNull String type, @NotNull String id) Creates an instance of aXmlComponentrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.fields()Returns the value of thefieldsrecord component.final inthashCode()Returns a hash code value for this object.@NotNull Stringid()Returns the value of theidrecord component.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.@NotNull RenderPriorityReturns the value of therenderPriorityrecord component.final StringtoString()Returns a string representation of this record class.@NotNull Stringtype()Returns the value of thetyperecord component.
-
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 aXmlComponentrecord class.- Parameters:
fields- the value for thefieldsrecord componentrenderPriority- the value for therenderPriorityrecord componenttype- the value for thetyperecord componentid- the value for theidrecord 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- TheGuiEngineApiinstance to use for object conversion.transformer- TheFunctionto 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
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. -
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. -
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). -
fields
Returns the value of thefieldsrecord component.- Returns:
- the value of the
fieldsrecord component
-
renderPriority
Returns the value of therenderPriorityrecord component.- Returns:
- the value of the
renderPriorityrecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-