Class NullVisibilitySwitcher

java.lang.Object
org.eclipse.yasson.internal.serializer.NullVisibilitySwitcher
All Implemented Interfaces:
ModelSerializer

class NullVisibilitySwitcher extends Object implements ModelSerializer
Switching mechanism for default null value visibility in the JSON. Some constructs such as arrays, collections etc. require to have nulls serialized into the JSON by default. This class switches from the default parent null visibility to the current construct visibility. As soon as the current construct is serialized, visibility is switched back to the parent ones.
  • Field Details

    • nullsEnabled

      private final boolean nullsEnabled
    • delegate

      private final ModelSerializer delegate
  • Constructor Details

    • NullVisibilitySwitcher

      NullVisibilitySwitcher(boolean nullsEnabled, ModelSerializer delegate)
  • Method Details

    • serialize

      public void serialize(Object value, jakarta.json.stream.JsonGenerator generator, SerializationContextImpl context)
      Description copied from interface: ModelSerializer
      Serialize provided value or delegate serialization to the next serializer.
      Specified by:
      serialize in interface ModelSerializer
      Parameters:
      value - value to be serialized
      generator - json generator
      context - serialization context