Skip to content

Commit

Permalink
Merge pull request #804 from microsoft/feature/code-reduction-generators
Browse files Browse the repository at this point in the history
feature/code reduction generators
  • Loading branch information
baywet authored Nov 10, 2023
2 parents 0a5cb30 + 41f8f6e commit 52bdd41
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.9.0] - 2023-11-10

### Added

- Added helper methods to request information to reduce the amount of generated code. [Kiota #3651](https://github.com/microsoft/kiota/issues/3651)

### Changed

- Kiota-Java has moved away from Async/Completable futures, thus Async components are no longer utilized and have been removed. Furthermore, requestAdapter methods no longer use the async suffix. [#175](https://github.com/microsoft/kiota-java/issues/175)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,46 @@ public class RequestInformation {
/** Creates a new instance of the request information class. */
public RequestInformation() { //Default constructor
}
/**
* Creates a new instance of the request information class.
* @param method The HTTP method for the request.
* @param urlTemplate The url template for the request.
* @param pathParameters The path parameters for the request.
*/
public RequestInformation(@Nonnull final HttpMethod method, @Nonnull final String urlTemplate, @Nonnull final Map<String, Object> pathParameters) {
this.httpMethod = Objects.requireNonNull(method);
this.urlTemplate = Objects.requireNonNull(urlTemplate);
this.pathParameters = Objects.requireNonNull(pathParameters);
}
/**
* Configures the request information based on the request configuration and the query parameters getter.
* @param <T> The type of the request configuration.
* @param requestConfiguration The request configuration to apply to the request information.
* @param configurationFactory The factory to create the request configuration from.
*/
public <T extends BaseRequestConfiguration> void configure(@Nullable final java.util.function.Consumer<T> requestConfiguration, @Nonnull final java.util.function.Supplier<T> configurationFactory) {
configure(requestConfiguration, configurationFactory, null);
}
/**
* Configures the request information based on the request configuration and the query parameters getter.
* @param <T> The type of the request configuration.
* @param requestConfiguration The request configuration to apply to the request information.
* @param configurationFactory The factory to create the request configuration from.
* @param queryParametersGetter The function to get the query parameters from the request configuration.
*/
public <T extends BaseRequestConfiguration> void configure(@Nullable final java.util.function.Consumer<T> requestConfiguration, @Nonnull final java.util.function.Supplier<T> configurationFactory, @Nullable final java.util.function.Function<T, Object> queryParametersGetter) {
Objects.requireNonNull(configurationFactory);
if (requestConfiguration == null) {
return;
}
final T requestConfig = configurationFactory.get();
requestConfiguration.accept(requestConfig);
if (queryParametersGetter != null) {
addQueryParameters(queryParametersGetter.apply(requestConfig));
}
headers.putAll(requestConfig.headers);
addRequestOptions(requestConfig.options);
}
/** The url template for the current request */
@Nullable
public String urlTemplate;
Expand Down

0 comments on commit 52bdd41

Please sign in to comment.