Skip to content

Commit

Permalink
use supplier
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP committed Dec 6, 2023
1 parent c24d44d commit 4ec7808
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import jakarta.annotation.Nonnull;

import java.util.Objects;
import java.util.function.Supplier;

/** Provides a builder for creating an ApiClient and register the default serializers/deserializers. */
public class ApiClientBuilder {
Expand All @@ -18,22 +19,24 @@ private ApiClientBuilder() {}

/**
* Registers the default serializer to the registry.
* @param factory the class of the factory to be registered.
* @param factorySupplier the supplier of the factory to be registered.
*/
public static void registerDefaultSerializer(
@Nonnull final SerializationWriterFactory factory) {
Objects.requireNonNull(factory);
@Nonnull final Supplier<SerializationWriterFactory> factorySupplier) {
Objects.requireNonNull(factorySupplier);
SerializationWriterFactory factory = factorySupplier.get();
SerializationWriterFactoryRegistry.defaultInstance.contentTypeAssociatedFactories.put(
factory.getValidContentType(), factory);
}

/**
* Registers the default deserializer to the registry.
* @param factory the class of the factory to be registered.
* @param factorySupplier the supplier of the factory to be registered.
*/
public static void registerDefaultDeserializer(
@Nonnull final ParseNodeFactory factory) {
Objects.requireNonNull(factory);
@Nonnull final Supplier<ParseNodeFactory> factorySupplier) {
Objects.requireNonNull(factorySupplier);
ParseNodeFactory factory = factorySupplier.get();
ParseNodeFactoryRegistry.defaultInstance.contentTypeAssociatedFactories.put(
factory.getValidContentType(), factory);
}
Expand Down

0 comments on commit 4ec7808

Please sign in to comment.