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 aXmlComponent
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.fields()
Returns the value of thefields
record component.final int
hashCode()
Returns a hash code value for this object.@NotNull String
id()
Returns the value of theid
record 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 RenderPriority
Returns the value of therenderPriority
record component.final String
toString()
Returns a string representation of this record class.@NotNull String
type()
Returns the value of thetype
record 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 aXmlComponent
record class.- Parameters:
fields
- the value for thefields
record componentrenderPriority
- the value for therenderPriority
record componenttype
- the value for thetype
record componentid
- the value for theid
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
- TheGuiEngineApi
instance to use for object conversion.transformer
- TheFunction
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
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 thefields
record component.- Returns:
- the value of the
fields
record component
-
renderPriority
Returns the value of therenderPriority
record component.- Returns:
- the value of the
renderPriority
record component
-
type
Returns the value of thetype
record component.- Returns:
- the value of the
type
record component
-
id
Returns the value of theid
record component.- Returns:
- the value of the
id
record component
-