Record Class JsonProperty<T,U>

java.lang.Object
java.lang.Record
net.tangly.gleam.model.JsonProperty<T,U>
Type Parameters:
T - type of the entity owning the field
U - type of the property
Record Components:
key - name of the property containing the JSON array
getter - getter of the property - returns an item of type U from an object of type T
setter - setter of the property of type U to the object of type T
extracts - conversion function between a JSON object and a Java object of type U
inserts - conversion function between a Java object of type U and a JSON object type
All Implemented Interfaces:
JsonField<T,U>

public record JsonProperty<T,U>(@NotNull String key, @NotNull Function<T,U> getter, @NotNull BiConsumer<T,U> setter, @NotNull Function<org.json.JSONObject,U> extracts, @NotNull BiFunction<U,org.json.JSONObject,org.json.JSONObject> inserts) extends Record implements JsonField<T,U>
Defines a JSON property mapping a Java class to a JSON entity property or mapping a simple property to a simple JSON property.

The API defines two sets of services

  • the first protocol defines how the property of type U is converted to and from a JSON representation. The JSON key under which the JSON representation is stored in the JSON structure is also accessible. This protocol is defined in JsonField
  • the second protocol defines how the JSON representation can be written to or read from the Java instance.