Record Class JsonArray<T,U>
java.lang.Object
java.lang.Record
net.tangly.gleam.model.JsonArray<T,U>
- Type Parameters:
T
- type of the entity owning the fieldU
- type of the common ancestor for the entities stored in the array- Record Components:
key
- name of the property containing the JSON arraygetter
- getter of the property - returns a collection of itemssetter
- setter used to add an item to the collection mapping the JSON arrayimportSelector
- selector to identify the type of the collection item based on any discriminator in the JSON arrayexportSelector
- selector to identify the type of the collection item based on any discriminator of the Java object
- All Implemented Interfaces:
JsonField<T,
U>
public record JsonArray<T,U> (@NotNull String key, @NotNull Function<T,Collection<U>> getter, @NotNull BiConsumer<T,U> setter, Function<org.json.JSONObject,JsonEntity<?>> importSelector, Function<Object,JsonEntity<?>> exportSelector)
extends Record
implements JsonField<T,U>
Define a field containing an array of entities. The entities can be of different types but must have a common ancestor.
-
Constructor Summary
ConstructorDescriptionJsonArray
(@NotNull String key, @NotNull Function<T, Collection<U>> getter, @NotNull BiConsumer<T, U> setter, Function<org.json.JSONObject, JsonEntity<?>> importSelector, Function<Object, JsonEntity<?>> exportSelector) Creates an instance of aJsonArray
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.void
Export the JSON value from the associated property after an optional conversion.Function
<Object, JsonEntity<?>> Returns the value of theexportSelector
record component.@NotNull Function
<T, Collection<U>> getter()
Returns the value of thegetter
record component.final int
hashCode()
Returns a hash code value for this object.void
Import the JSON value and set the associated property after an optional conversion.Function
<org.json.JSONObject, JsonEntity<?>> Returns the value of theimportSelector
record component.@NotNull String
key()
Returns the value of thekey
record component.@NotNull BiConsumer
<T, U> setter()
Returns the value of thesetter
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
JsonArray
public JsonArray(@NotNull @NotNull String key, @NotNull @NotNull Function<T, Collection<U>> getter, @NotNull @NotNull BiConsumer<T, U> setter, Function<org.json.JSONObject, JsonEntity<?>> importSelector, Function<Object, JsonEntity<?>> exportSelector) Creates an instance of aJsonArray
record class.- Parameters:
key
- the value for thekey
record componentgetter
- the value for thegetter
record componentsetter
- the value for thesetter
record componentimportSelector
- the value for theimportSelector
record componentexportSelector
- the value for theexportSelector
record component
-
-
Method Details
-
exports
Description copied from interface:JsonField
Export the JSON value from the associated property after an optional conversion. Multiple JSON values can be written if the object is a complex one. -
imports
Description copied from interface:JsonField
Import the JSON value and set the associated property after an optional conversion. Multiple JSON values can be used if the object is complex. -
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)
. -
key
-
getter
-
setter
-
importSelector
Returns the value of theimportSelector
record component.- Returns:
- the value of the
importSelector
record component
-
exportSelector
Returns the value of theexportSelector
record component.- Returns:
- the value of the
exportSelector
record component
-