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
ConstructorsConstructorDescriptionJsonArray(@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 aJsonArrayrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.voidExport the JSON value from the associated property after an optional conversion.Function<Object, JsonEntity<?>> Returns the value of theexportSelectorrecord component.@NotNull Function<T, Collection<U>> getter()Returns the value of thegetterrecord component.final inthashCode()Returns a hash code value for this object.voidImport the JSON value and set the associated property after an optional conversion.Function<org.json.JSONObject, JsonEntity<?>> Returns the value of theimportSelectorrecord component.@NotNull Stringkey()Returns the value of thekeyrecord component.@NotNull BiConsumer<T, U> setter()Returns the value of thesetterrecord component.final StringtoString()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 aJsonArrayrecord class.- Parameters:
key- the value for thekeyrecord componentgetter- the value for thegetterrecord componentsetter- the value for thesetterrecord componentimportSelector- the value for theimportSelectorrecord componentexportSelector- the value for theexportSelectorrecord component
-
-
Method Details
-
exports
Description copied from interface:JsonFieldExport 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:JsonFieldImport 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 theimportSelectorrecord component.- Returns:
- the value of the
importSelectorrecord component
-
exportSelector
Returns the value of theexportSelectorrecord component.- Returns:
- the value of the
exportSelectorrecord component
-