Package ru.tinkoff.kora.json.common
Interface JsonNullable<T>
- All Known Implementing Classes:
JsonNullable.Defined,JsonNullable.Undefined
Русский: Специальный тип который позволяет указывать как записывать/считывать поля из JSON в состояниях, когда
поле указано и/или является `null` или не является `null` в JSON
Работает как для
English: A special type that allows you to specify how to write/read fields from JSON in states where the field is specified and/or is `null` or is not `null` in JSON Works for both
Пример / Example:
JsonWriter так и JsonReader
English: A special type that allows you to specify how to write/read fields from JSON in states where the field is specified and/or is `null` or is not `null` in JSON Works for both
JsonWriter and JsonReader
Пример / Example:
@Json
record Example(JsonNullable<String> definedNonNull,
JsonNullable<String> definedNull,
JsonNullable<String> undefined) { }
→
jsonWriter.toByteArray(
new Example(JsonNullable.of("Interstellar"),
JsonNullable.nullValue(),
JsonNullable.undefined())
);
JsonNullable.undefined() is fully omitted cause it is undefined →
{ "definedNonNull": "Interstellar", "definedNull": null }
Sa-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordstatic final record -
Method Summary
Modifier and TypeMethodDescriptionbooleandefault booleanisNull()static <T> JsonNullable<T>static <T> JsonNullable<T>of(T value) static <T> JsonNullable<T>ofNullable(T value) static <T> JsonNullable<T>value()
-
Method Details
-
isDefined
boolean isDefined() -
isNull
default boolean isNull() -
value
-
undefined
-
nullValue
-
of
-
ofNullable
-