Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
12 changes: 12 additions & 0 deletions .chronus/changes/main-2026-8-9-11-42-59.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
changeKind: feature
packages:
- "@typespec/http-client-java"
---

Sort generated Java members after customizations and partial updates, keeping related service overloads together:

```java
getWidget();
getWidgetWithResponse();
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
*/
@ServiceClient(builder = ApiKeyClientBuilder.class)
public final class ApiKeyClient {
@Metadata(properties = { MetadataProperties.GENERATED })
private final ApiKeyClientImpl serviceClient;

private final Instrumentation instrumentation;

@Metadata(properties = { MetadataProperties.GENERATED })
private final ApiKeyClientImpl serviceClient;

/**
* Initializes an instance of ApiKeyClient class.
*
*
* @param serviceClient the service client implementation.
* @param instrumentation the instrumentation instance.
*/
Expand All @@ -35,57 +36,57 @@ public final class ApiKeyClient {

/**
* Check whether client is authenticated.
*
* @param requestContext The context to configure the HTTP request before HTTP client sends it.
* @throws IllegalArgumentException thrown if parameters fail the validation.
*
* @throws HttpResponseException thrown if the service returns an error.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link Response}.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> validWithResponse(RequestContext requestContext) {
return this.instrumentation.instrumentWithResponse("Authentication.ApiKey.valid", requestContext,
updatedContext -> this.serviceClient.validWithResponse(updatedContext));
public void invalid() {
invalidWithResponse(RequestContext.none());
}

/**
* Check whether client is authenticated.
*
*
* @param requestContext The context to configure the HTTP request before HTTP client sends it.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the service returns an error.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link Response}.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
@ServiceMethod(returns = ReturnType.SINGLE)
public void valid() {
validWithResponse(RequestContext.none());
public Response<Void> invalidWithResponse(RequestContext requestContext) {
return this.instrumentation.instrumentWithResponse("Authentication.ApiKey.invalid", requestContext,
updatedContext -> this.serviceClient.invalidWithResponse(updatedContext));
}

/**
* Check whether client is authenticated.
*
* @param requestContext The context to configure the HTTP request before HTTP client sends it.
* @throws IllegalArgumentException thrown if parameters fail the validation.
*
* @throws HttpResponseException thrown if the service returns an error.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link Response}.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> invalidWithResponse(RequestContext requestContext) {
return this.instrumentation.instrumentWithResponse("Authentication.ApiKey.invalid", requestContext,
updatedContext -> this.serviceClient.invalidWithResponse(updatedContext));
public void valid() {
validWithResponse(RequestContext.none());
}

/**
* Check whether client is authenticated.
*
*
* @param requestContext The context to configure the HTTP request before HTTP client sends it.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the service returns an error.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link Response}.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
@ServiceMethod(returns = ReturnType.SINGLE)
public void invalid() {
invalidWithResponse(RequestContext.none());
public Response<Void> validWithResponse(RequestContext requestContext) {
return this.instrumentation.instrumentWithResponse("Authentication.ApiKey.valid", requestContext,
updatedContext -> this.serviceClient.validWithResponse(updatedContext));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,41 +38,60 @@
public final class ApiKeyClientBuilder
implements HttpTrait<ApiKeyClientBuilder>, ProxyTrait<ApiKeyClientBuilder>, ConfigurationTrait<ApiKeyClientBuilder>,
KeyCredentialTrait<ApiKeyClientBuilder>, EndpointTrait<ApiKeyClientBuilder> {

@Metadata(properties = { MetadataProperties.GENERATED })
private static final String SDK_NAME = "name";
private static final Map<String, String> PROPERTIES = CoreUtils.getProperties("authentication-apikey.properties");

@Metadata(properties = { MetadataProperties.GENERATED })
private static final String SDK_VERSION = "version";
private static final String SDK_NAME = "name";

@Metadata(properties = { MetadataProperties.GENERATED })
private static final Map<String, String> PROPERTIES = CoreUtils.getProperties("authentication-apikey.properties");
private static final String SDK_VERSION = "version";

/*
* The configuration store that is used during construction of the service client.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
private final List<HttpPipelinePolicy> pipelinePolicies;
private Configuration configuration;

/**
* Create an instance of the ApiKeyClientBuilder.
/*
* The service endpoint
*/
@Metadata(properties = { MetadataProperties.GENERATED })
public ApiKeyClientBuilder() {
this.pipelinePolicies = new ArrayList<>();
}
private String endpoint;

/*
* The HTTP client used to send the request.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
private HttpClient httpClient;

/**
* {@inheritDoc}.
/*
* The instrumentation configuration for HTTP requests and responses.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
@Override
public ApiKeyClientBuilder httpClient(HttpClient httpClient) {
this.httpClient = httpClient;
return this;
}
private HttpInstrumentationOptions httpInstrumentationOptions;

/*
* The KeyCredential used for authentication.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
private KeyCredential keyCredential;

@Metadata(properties = { MetadataProperties.GENERATED })
private final List<HttpPipelinePolicy> pipelinePolicies;

/*
* The proxy options used during construction of the service client.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
private ProxyOptions proxyOptions;

/*
* The redirect options to configure redirect policy
*/
@Metadata(properties = { MetadataProperties.GENERATED })
private HttpRedirectOptions redirectOptions;

/*
* The retry options to configure retry policy for failed requests.
Expand All @@ -81,13 +100,11 @@ public ApiKeyClientBuilder httpClient(HttpClient httpClient) {
private HttpRetryOptions retryOptions;

/**
* {@inheritDoc}.
* Create an instance of the ApiKeyClientBuilder.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
@Override
public ApiKeyClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) {
this.retryOptions = retryOptions;
return this;
public ApiKeyClientBuilder() {
this.pipelinePolicies = new ArrayList<>();
}

/**
Expand All @@ -101,105 +118,100 @@ public ApiKeyClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy
return this;
}

/*
* The redirect options to configure redirect policy
*/
@Metadata(properties = { MetadataProperties.GENERATED })
private HttpRedirectOptions redirectOptions;

/**
* {@inheritDoc}.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
@Override
public ApiKeyClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) {
this.redirectOptions = redirectOptions;
public ApiKeyClientBuilder configuration(Configuration configuration) {
this.configuration = configuration;
return this;
}

/*
* The instrumentation configuration for HTTP requests and responses.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
private HttpInstrumentationOptions httpInstrumentationOptions;

/**
* {@inheritDoc}.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
@Override
public ApiKeyClientBuilder httpInstrumentationOptions(HttpInstrumentationOptions httpInstrumentationOptions) {
this.httpInstrumentationOptions = httpInstrumentationOptions;
public ApiKeyClientBuilder credential(KeyCredential keyCredential) {
this.keyCredential = keyCredential;
return this;
}

/*
* The proxy options used during construction of the service client.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
private ProxyOptions proxyOptions;

/**
* {@inheritDoc}.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
@Override
public ApiKeyClientBuilder proxyOptions(ProxyOptions proxyOptions) {
this.proxyOptions = proxyOptions;
public ApiKeyClientBuilder endpoint(String endpoint) {
this.endpoint = endpoint;
return this;
}

/*
* The configuration store that is used during construction of the service client.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
private Configuration configuration;

/**
* {@inheritDoc}.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
@Override
public ApiKeyClientBuilder configuration(Configuration configuration) {
this.configuration = configuration;
public ApiKeyClientBuilder httpClient(HttpClient httpClient) {
this.httpClient = httpClient;
return this;
}

/*
* The KeyCredential used for authentication.
/**
* {@inheritDoc}.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
private KeyCredential keyCredential;
@Override
public ApiKeyClientBuilder httpInstrumentationOptions(HttpInstrumentationOptions httpInstrumentationOptions) {
this.httpInstrumentationOptions = httpInstrumentationOptions;
return this;
}

/**
* {@inheritDoc}.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
@Override
public ApiKeyClientBuilder credential(KeyCredential keyCredential) {
this.keyCredential = keyCredential;
public ApiKeyClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) {
this.redirectOptions = redirectOptions;
return this;
}

/*
* The service endpoint
/**
* {@inheritDoc}.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
private String endpoint;
@Override
public ApiKeyClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) {
this.retryOptions = retryOptions;
return this;
}

/**
* {@inheritDoc}.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
@Override
public ApiKeyClientBuilder endpoint(String endpoint) {
this.endpoint = endpoint;
public ApiKeyClientBuilder proxyOptions(ProxyOptions proxyOptions) {
this.proxyOptions = proxyOptions;
return this;
}

/**
* Builds an instance of ApiKeyClient class.
*
* @return an instance of ApiKeyClient.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
public ApiKeyClient buildClient() {
ApiKeyClientImpl innerClient = buildInnerClient();
return new ApiKeyClient(innerClient, innerClient.getInstrumentation());
}

/**
* Builds an instance of ApiKeyClientImpl with the provided parameters.
*
*
* @return an instance of ApiKeyClientImpl.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
Expand All @@ -219,12 +231,6 @@ private ApiKeyClientImpl buildInnerClient() {
return client;
}

@Metadata(properties = { MetadataProperties.GENERATED })
private void validateClient() {
// This method is invoked from 'buildInnerClient'/'buildClient' method.
// Developer can customize this method, to validate that the necessary conditions are met for the new client.
}

@Metadata(properties = { MetadataProperties.GENERATED })
private HttpPipeline createHttpPipeline() {
Configuration buildConfiguration
Expand All @@ -245,14 +251,9 @@ private HttpPipeline createHttpPipeline() {
return httpPipelineBuilder.httpClient(httpClient).build();
}

/**
* Builds an instance of ApiKeyClient class.
*
* @return an instance of ApiKeyClient.
*/
@Metadata(properties = { MetadataProperties.GENERATED })
public ApiKeyClient buildClient() {
ApiKeyClientImpl innerClient = buildInnerClient();
return new ApiKeyClient(innerClient, innerClient.getInstrumentation());
private void validateClient() {
// This method is invoked from 'buildInnerClient'/'buildClient' method.
// Developer can customize this method, to validate that the necessary conditions are met for the new client.
}
}
Loading
Loading