All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.avaje.jsonb.inject.DefaultJsonbProvider Maven / Gradle / Ivy

There is a newer version: 3.0-RC5
Show newest version
package io.avaje.jsonb.inject;

import io.avaje.inject.BeanScopeBuilder;
import io.avaje.jsonb.Jsonb;

/** Plugin for avaje inject that provides a default Jsonb instance. */
public final class DefaultJsonbProvider implements io.avaje.inject.spi.Plugin {

  @Override
  public Class[] provides() {
    return new Class[] {Jsonb.class};
  }

  @Override
  public void apply(BeanScopeBuilder builder) {
    builder.provideDefault(
        null,
        Jsonb.class,
        () -> {
          var props = builder.propertyPlugin();

          return Jsonb.builder()
              .failOnUnknown(props.equalTo("jsonb.deserialize.failOnUnknown", "true"))
              .mathTypesAsString(props.equalTo("jsonb.serialize.mathTypesAsString", "true"))
              .serializeEmpty(props.notEqualTo("jsonb.serialize.empty", "false"))
              .serializeNulls(props.equalTo("jsonb.serialize.nulls", "true"))
              .build();
        });
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy