diff --git a/CHANGELOG.md b/CHANGELOG.md index 4787e2512..0f327c353 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +## [0.11.0] - 2023-12-06 + +### Changed + +- [breaking] Removed the usage of reflection in `ApiClientBuilder` + ## [0.10.0] - 2023-11-22 ### Changed diff --git a/components/abstractions/src/main/java/com/microsoft/kiota/ApiClientBuilder.java b/components/abstractions/src/main/java/com/microsoft/kiota/ApiClientBuilder.java index fb219654e..b23b2b870 100644 --- a/components/abstractions/src/main/java/com/microsoft/kiota/ApiClientBuilder.java +++ b/components/abstractions/src/main/java/com/microsoft/kiota/ApiClientBuilder.java @@ -9,8 +9,8 @@ import jakarta.annotation.Nonnull; -import java.lang.reflect.InvocationTargetException; 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 { @@ -19,40 +19,26 @@ private ApiClientBuilder() {} /** * Registers the default serializer to the registry. - * @param factoryClass the class of the factory to be registered. + * @param factorySupplier the supplier of the factory to be registered. */ public static void registerDefaultSerializer( - @Nonnull final Class factoryClass) { - Objects.requireNonNull(factoryClass); - try { - final SerializationWriterFactory factory = factoryClass.getConstructor().newInstance(); - SerializationWriterFactoryRegistry.defaultInstance.contentTypeAssociatedFactories.put( - factory.getValidContentType(), factory); - } catch (InstantiationException - | IllegalAccessException - | NoSuchMethodException - | InvocationTargetException e) { - throw new RuntimeException(e); - } + @Nonnull final Supplier factorySupplier) { + Objects.requireNonNull(factorySupplier); + SerializationWriterFactory factory = factorySupplier.get(); + SerializationWriterFactoryRegistry.defaultInstance.contentTypeAssociatedFactories.put( + factory.getValidContentType(), factory); } /** * Registers the default deserializer to the registry. - * @param factoryClass the class of the factory to be registered. + * @param factorySupplier the supplier of the factory to be registered. */ public static void registerDefaultDeserializer( - @Nonnull final Class factoryClass) { - Objects.requireNonNull(factoryClass); - try { - final ParseNodeFactory factory = factoryClass.getConstructor().newInstance(); - ParseNodeFactoryRegistry.defaultInstance.contentTypeAssociatedFactories.put( - factory.getValidContentType(), factory); - } catch (InstantiationException - | IllegalAccessException - | NoSuchMethodException - | InvocationTargetException e) { - throw new RuntimeException(e); - } + @Nonnull final Supplier factorySupplier) { + Objects.requireNonNull(factorySupplier); + ParseNodeFactory factory = factorySupplier.get(); + ParseNodeFactoryRegistry.defaultInstance.contentTypeAssociatedFactories.put( + factory.getValidContentType(), factory); } /** diff --git a/gradle.properties b/gradle.properties index 7524b49e2..f49ea8b08 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,7 +25,7 @@ org.gradle.caching=true mavenGroupId = com.microsoft.kiota mavenMajorVersion = 0 -mavenMinorVersion = 10 +mavenMinorVersion = 11 mavenPatchVersion = 0 mavenArtifactSuffix =