Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions Templates/templates/Java/requests/BaseClient.java.tt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import <#=importNamespace#>.authentication.IAuthenticationProvider;
import <#=importNamespace#>.logger.ILogger;
import <#=importNamespace#>.serializer.ISerializer;
import okhttp3.OkHttpClient;
import okhttp3.Request;

<#=TypeHelperJava.CreateClassDef(c.TypeName() + "Client", c.BaseClientType(), "IBaseClient", c.Deprecation?.Description)#>
<#=TypeHelperJava.CreateClassDef(c.TypeName() + "Client<nativeRequestType>", c.BaseClientType() + "<nativeRequestType>", "IBaseClient<nativeRequestType>", c.Deprecation?.Description, " * @param <nativeRequestType> type of a request for the native http client")#>
/**
* Restricted constructor
*/
Expand All @@ -35,13 +36,28 @@ import okhttp3.OkHttpClient;
* @return builder to start configuring the client
*/
@Nonnull
public static Builder<OkHttpClient> builder() {
public static Builder<OkHttpClient, Request> builder() {
return builder(OkHttpClient.class, Request.class);
}

/**
* Gets the builder to start configuring the client
*
* @param <nativeClient> the type of the native http client
* @param <nativeRequest> the type of the native http request
* @param nativeClientClass the class of the native http client
* @param nativeRequestClass the class of the native http request
* @return builder to start configuring the client
*/
@Nonnull
public static <nativeClient, nativeRequest> Builder<nativeClient, nativeRequest> builder(Class<nativeClient> nativeClientClass, Class<nativeRequest> nativeRequestClass) {
return new Builder<>();
}
/**
* Builder to help configure the Graph service client
* @param <nativeRequestType> type of a request for the native http client
*/
public static class Builder<httpClientType> extends BaseClient.Builder<httpClientType> {
public static class Builder<httpClientType, nativeRequestType> extends BaseClient.Builder<httpClientType, nativeRequestType> {
/**
* Sets the serializer.
*
Expand All @@ -51,7 +67,7 @@ import okhttp3.OkHttpClient;
*/
@Nonnull
@Override
public Builder<httpClientType> serializer(@Nonnull final ISerializer serializer) {
public Builder<httpClientType, nativeRequestType> serializer(@Nonnull final ISerializer serializer) {
super.serializer(serializer);
return this;
}
Expand All @@ -65,7 +81,7 @@ import okhttp3.OkHttpClient;
*/
@Nonnull
@Override
public Builder<httpClientType> httpProvider(@Nonnull final IHttpProvider httpProvider) {
public Builder<httpClientType, nativeRequestType> httpProvider(@Nonnull final IHttpProvider httpProvider) {
super.httpProvider(httpProvider);
return this;
}
Expand All @@ -79,7 +95,7 @@ import okhttp3.OkHttpClient;
*/
@Nonnull
@Override
public Builder<httpClientType> logger(@Nonnull final ILogger logger) {
public Builder<httpClientType, nativeRequestType> logger(@Nonnull final ILogger logger) {
super.logger(logger);
return this;
}
Expand All @@ -93,7 +109,7 @@ import okhttp3.OkHttpClient;
*/
@Nonnull
@Override
public Builder<httpClientType> httpClient(@Nonnull final httpClientType client) {
public Builder<httpClientType, nativeRequestType> httpClient(@Nonnull final httpClientType client) {
super.httpClient(client);
return this;
}
Expand All @@ -106,7 +122,7 @@ import okhttp3.OkHttpClient;
*/
@Nonnull
@Override
public Builder<httpClientType> authenticationProvider(@Nonnull final IAuthenticationProvider auth) {
public Builder<httpClientType, nativeRequestType> authenticationProvider(@Nonnull final IAuthenticationProvider auth) {
super.authenticationProvider(auth);
return this;
}
Expand Down
18 changes: 10 additions & 8 deletions src/GraphODataTemplateWriter/CodeHelpers/Java/TypeHelperJava.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,17 +1211,17 @@ public static string CreatePropertyDef(IEnumerable<OdcmProperty> properties, boo
/// name = the name of the class
/// extends = the class it extends
/// implements = the interface it extends
public static string CreateClassDef(string name, string extends, string implements, string deprecationDescription)
public static string CreateClassDef(string name, string extends, string implements, string deprecationDescription, string additionalParamsDescription = null)
{
return CreateClassOrInterface(name, true, extends, implements, deprecationDescription);
return CreateClassOrInterface(name, true, extends, implements, deprecationDescription, additionalParamsDescription);
}

public static string CreateInterfaceDef(string name, string extends, string deprecationDescription)
public static string CreateInterfaceDef(string name, string extends, string deprecationDescription, string additionalParamsDescription = null)
{
return CreateClassOrInterface(name, false, extends, null, deprecationDescription);
return CreateClassOrInterface(name, false, extends, null, deprecationDescription, additionalParamsDescription);
}

public static string CreateClassOrInterface(string name, bool isClass = true, string extends = null, string implements = null, string deprecationDescription = null)
public static string CreateClassOrInterface(string name, bool isClass = true, string extends = null, string implements = null, string deprecationDescription = null, string additionalParamsDescription = null)
{
var extendsStr = string.Empty;
if (!string.IsNullOrEmpty(extends))
Expand All @@ -1234,21 +1234,23 @@ public static string CreateClassOrInterface(string name, bool isClass = true, st
{
implementsStr = string.Format(" implements {0}", implements);
}
var nonGenericName = name.Split(new char [] {'<'}, StringSplitOptions.RemoveEmptyEntries).First();

var format = @"

/**
* The {1} for the {0}.{2}
* The {1} for the {0}.{7}{2}
*/{3}
public {1} {4}{5}{6} {{";
string declaration = string.Format(format,
isClass ? name.SplitCamelCase() : name.SplitCamelCase().Remove(0, 1),
isClass ? nonGenericName.SplitCamelCase() : nonGenericName.SplitCamelCase().Remove(0, 1),
isClass ? "class" : "interface",
string.IsNullOrEmpty(deprecationDescription) ? string.Empty : $"\r\n * @deprecated {deprecationDescription}",
string.IsNullOrEmpty(deprecationDescription) ? string.Empty : "\r\n@Deprecated",
name,
extendsStr,
implementsStr);
implementsStr,
string.IsNullOrEmpty(additionalParamsDescription) ? string.Empty : $"\r\n{additionalParamsDescription}");

return CreatAutogeneratedWarning() + declaration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
import com.microsoft.graph.logger.ILogger;
import com.microsoft.graph.serializer.ISerializer;
import okhttp3.OkHttpClient;
import okhttp3.Request;

// **NOTE** This file was generated by a tool and any changes will be overwritten.

/**
* The class for the Graph Service Client.
* @param <nativeRequestType> type of a request for the native http client
*/
public class GraphServiceClient extends BaseClient implements IBaseClient {
public class GraphServiceClient<nativeRequestType> extends BaseClient<nativeRequestType> implements IBaseClient<nativeRequestType> {
/**
* Restricted constructor
*/
Expand All @@ -51,13 +53,28 @@ public String getServiceSDKVersion() {
* @return builder to start configuring the client
*/
@Nonnull
public static Builder<OkHttpClient> builder() {
public static Builder<OkHttpClient, Request> builder() {
return builder(OkHttpClient.class, Request.class);
}

/**
* Gets the builder to start configuring the client
*
* @param <nativeClient> the type of the native http client
* @param <nativeRequest> the type of the native http request
* @param nativeClientClass the class of the native http client
* @param nativeRequestClass the class of the native http request
* @return builder to start configuring the client
*/
@Nonnull
public static <nativeClient, nativeRequest> Builder<nativeClient, nativeRequest> builder(Class<nativeClient> nativeClientClass, Class<nativeRequest> nativeRequestClass) {
return new Builder<>();
}
/**
* Builder to help configure the Graph service client
* @param <nativeRequestType> type of a request for the native http client
*/
public static class Builder<httpClientType> extends BaseClient.Builder<httpClientType> {
public static class Builder<httpClientType, nativeRequestType> extends BaseClient.Builder<httpClientType, nativeRequestType> {
/**
* Sets the serializer.
*
Expand All @@ -67,7 +84,7 @@ public static class Builder<httpClientType> extends BaseClient.Builder<httpClien
*/
@Nonnull
@Override
public Builder<httpClientType> serializer(@Nonnull final ISerializer serializer) {
public Builder<httpClientType, nativeRequestType> serializer(@Nonnull final ISerializer serializer) {
super.serializer(serializer);
return this;
}
Expand All @@ -81,7 +98,7 @@ public Builder<httpClientType> serializer(@Nonnull final ISerializer serializer)
*/
@Nonnull
@Override
public Builder<httpClientType> httpProvider(@Nonnull final IHttpProvider httpProvider) {
public Builder<httpClientType, nativeRequestType> httpProvider(@Nonnull final IHttpProvider httpProvider) {
super.httpProvider(httpProvider);
return this;
}
Expand All @@ -95,7 +112,7 @@ public Builder<httpClientType> httpProvider(@Nonnull final IHttpProvider httpPro
*/
@Nonnull
@Override
public Builder<httpClientType> logger(@Nonnull final ILogger logger) {
public Builder<httpClientType, nativeRequestType> logger(@Nonnull final ILogger logger) {
super.logger(logger);
return this;
}
Expand All @@ -109,7 +126,7 @@ public Builder<httpClientType> logger(@Nonnull final ILogger logger) {
*/
@Nonnull
@Override
public Builder<httpClientType> httpClient(@Nonnull final httpClientType client) {
public Builder<httpClientType, nativeRequestType> httpClient(@Nonnull final httpClientType client) {
super.httpClient(client);
return this;
}
Expand All @@ -122,7 +139,7 @@ public Builder<httpClientType> httpClient(@Nonnull final httpClientType client)
*/
@Nonnull
@Override
public Builder<httpClientType> authenticationProvider(@Nonnull final IAuthenticationProvider auth) {
public Builder<httpClientType, nativeRequestType> authenticationProvider(@Nonnull final IAuthenticationProvider auth) {
super.authenticationProvider(auth);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
import com.microsoft.graph.logger.ILogger;
import com.microsoft.graph.serializer.ISerializer;
import okhttp3.OkHttpClient;
import okhttp3.Request;

// **NOTE** This file was generated by a tool and any changes will be overwritten.

/**
* The class for the Graph Service Client.
* @param <nativeRequestType> type of a request for the native http client
*/
public class GraphServiceClient extends BaseClient implements IBaseClient {
public class GraphServiceClient<nativeRequestType> extends BaseClient<nativeRequestType> implements IBaseClient<nativeRequestType> {
/**
* Restricted constructor
*/
Expand All @@ -51,13 +53,28 @@ public String getServiceSDKVersion() {
* @return builder to start configuring the client
*/
@Nonnull
public static Builder<OkHttpClient> builder() {
public static Builder<OkHttpClient, Request> builder() {
return builder(OkHttpClient.class, Request.class);
}

/**
* Gets the builder to start configuring the client
*
* @param <nativeClient> the type of the native http client
* @param <nativeRequest> the type of the native http request
* @param nativeClientClass the class of the native http client
* @param nativeRequestClass the class of the native http request
* @return builder to start configuring the client
*/
@Nonnull
public static <nativeClient, nativeRequest> Builder<nativeClient, nativeRequest> builder(Class<nativeClient> nativeClientClass, Class<nativeRequest> nativeRequestClass) {
return new Builder<>();
}
/**
* Builder to help configure the Graph service client
* @param <nativeRequestType> type of a request for the native http client
*/
public static class Builder<httpClientType> extends BaseClient.Builder<httpClientType> {
public static class Builder<httpClientType, nativeRequestType> extends BaseClient.Builder<httpClientType, nativeRequestType> {
/**
* Sets the serializer.
*
Expand All @@ -67,7 +84,7 @@ public static class Builder<httpClientType> extends BaseClient.Builder<httpClien
*/
@Nonnull
@Override
public Builder<httpClientType> serializer(@Nonnull final ISerializer serializer) {
public Builder<httpClientType, nativeRequestType> serializer(@Nonnull final ISerializer serializer) {
super.serializer(serializer);
return this;
}
Expand All @@ -81,7 +98,7 @@ public Builder<httpClientType> serializer(@Nonnull final ISerializer serializer)
*/
@Nonnull
@Override
public Builder<httpClientType> httpProvider(@Nonnull final IHttpProvider httpProvider) {
public Builder<httpClientType, nativeRequestType> httpProvider(@Nonnull final IHttpProvider httpProvider) {
super.httpProvider(httpProvider);
return this;
}
Expand All @@ -95,7 +112,7 @@ public Builder<httpClientType> httpProvider(@Nonnull final IHttpProvider httpPro
*/
@Nonnull
@Override
public Builder<httpClientType> logger(@Nonnull final ILogger logger) {
public Builder<httpClientType, nativeRequestType> logger(@Nonnull final ILogger logger) {
super.logger(logger);
return this;
}
Expand All @@ -109,7 +126,7 @@ public Builder<httpClientType> logger(@Nonnull final ILogger logger) {
*/
@Nonnull
@Override
public Builder<httpClientType> httpClient(@Nonnull final httpClientType client) {
public Builder<httpClientType, nativeRequestType> httpClient(@Nonnull final httpClientType client) {
super.httpClient(client);
return this;
}
Expand All @@ -122,7 +139,7 @@ public Builder<httpClientType> httpClient(@Nonnull final httpClientType client)
*/
@Nonnull
@Override
public Builder<httpClientType> authenticationProvider(@Nonnull final IAuthenticationProvider auth) {
public Builder<httpClientType, nativeRequestType> authenticationProvider(@Nonnull final IAuthenticationProvider auth) {
super.authenticationProvider(auth);
return this;
}
Expand Down