diff --git a/Templates/templates/Java/requests/BaseClient.java.tt b/Templates/templates/Java/requests/BaseClient.java.tt index 7f8da1ce3..a5673198a 100644 --- a/Templates/templates/Java/requests/BaseClient.java.tt +++ b/Templates/templates/Java/requests/BaseClient.java.tt @@ -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", c.BaseClientType() + "", "IBaseClient", c.Deprecation?.Description, " * @param type of a request for the native http client")#> /** * Restricted constructor */ @@ -35,13 +36,28 @@ import okhttp3.OkHttpClient; * @return builder to start configuring the client */ @Nonnull - public static Builder builder() { + public static Builder builder() { + return builder(OkHttpClient.class, Request.class); + } + + /** + * Gets the builder to start configuring the client + * + * @param the type of the native http client + * @param 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 Builder builder(Class nativeClientClass, Class nativeRequestClass) { return new Builder<>(); } /** * Builder to help configure the Graph service client + * @param type of a request for the native http client */ - public static class Builder extends BaseClient.Builder { + public static class Builder extends BaseClient.Builder { /** * Sets the serializer. * @@ -51,7 +67,7 @@ import okhttp3.OkHttpClient; */ @Nonnull @Override - public Builder serializer(@Nonnull final ISerializer serializer) { + public Builder serializer(@Nonnull final ISerializer serializer) { super.serializer(serializer); return this; } @@ -65,7 +81,7 @@ import okhttp3.OkHttpClient; */ @Nonnull @Override - public Builder httpProvider(@Nonnull final IHttpProvider httpProvider) { + public Builder httpProvider(@Nonnull final IHttpProvider httpProvider) { super.httpProvider(httpProvider); return this; } @@ -79,7 +95,7 @@ import okhttp3.OkHttpClient; */ @Nonnull @Override - public Builder logger(@Nonnull final ILogger logger) { + public Builder logger(@Nonnull final ILogger logger) { super.logger(logger); return this; } @@ -93,7 +109,7 @@ import okhttp3.OkHttpClient; */ @Nonnull @Override - public Builder httpClient(@Nonnull final httpClientType client) { + public Builder httpClient(@Nonnull final httpClientType client) { super.httpClient(client); return this; } @@ -106,7 +122,7 @@ import okhttp3.OkHttpClient; */ @Nonnull @Override - public Builder authenticationProvider(@Nonnull final IAuthenticationProvider auth) { + public Builder authenticationProvider(@Nonnull final IAuthenticationProvider auth) { super.authenticationProvider(auth); return this; } diff --git a/src/GraphODataTemplateWriter/CodeHelpers/Java/TypeHelperJava.cs b/src/GraphODataTemplateWriter/CodeHelpers/Java/TypeHelperJava.cs index 7b5a9071f..1959bd07d 100644 --- a/src/GraphODataTemplateWriter/CodeHelpers/Java/TypeHelperJava.cs +++ b/src/GraphODataTemplateWriter/CodeHelpers/Java/TypeHelperJava.cs @@ -1211,17 +1211,17 @@ public static string CreatePropertyDef(IEnumerable 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)) @@ -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; } diff --git a/test/Typewriter.Test/TestDataJava/com/microsoft/graph/requests/GraphServiceClient.java b/test/Typewriter.Test/TestDataJava/com/microsoft/graph/requests/GraphServiceClient.java index c11e812de..197fe38c0 100644 --- a/test/Typewriter.Test/TestDataJava/com/microsoft/graph/requests/GraphServiceClient.java +++ b/test/Typewriter.Test/TestDataJava/com/microsoft/graph/requests/GraphServiceClient.java @@ -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 type of a request for the native http client */ -public class GraphServiceClient extends BaseClient implements IBaseClient { +public class GraphServiceClient extends BaseClient implements IBaseClient { /** * Restricted constructor */ @@ -51,13 +53,28 @@ public String getServiceSDKVersion() { * @return builder to start configuring the client */ @Nonnull - public static Builder builder() { + public static Builder builder() { + return builder(OkHttpClient.class, Request.class); + } + + /** + * Gets the builder to start configuring the client + * + * @param the type of the native http client + * @param 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 Builder builder(Class nativeClientClass, Class nativeRequestClass) { return new Builder<>(); } /** * Builder to help configure the Graph service client + * @param type of a request for the native http client */ - public static class Builder extends BaseClient.Builder { + public static class Builder extends BaseClient.Builder { /** * Sets the serializer. * @@ -67,7 +84,7 @@ public static class Builder extends BaseClient.Builder serializer(@Nonnull final ISerializer serializer) { + public Builder serializer(@Nonnull final ISerializer serializer) { super.serializer(serializer); return this; } @@ -81,7 +98,7 @@ public Builder serializer(@Nonnull final ISerializer serializer) */ @Nonnull @Override - public Builder httpProvider(@Nonnull final IHttpProvider httpProvider) { + public Builder httpProvider(@Nonnull final IHttpProvider httpProvider) { super.httpProvider(httpProvider); return this; } @@ -95,7 +112,7 @@ public Builder httpProvider(@Nonnull final IHttpProvider httpPro */ @Nonnull @Override - public Builder logger(@Nonnull final ILogger logger) { + public Builder logger(@Nonnull final ILogger logger) { super.logger(logger); return this; } @@ -109,7 +126,7 @@ public Builder logger(@Nonnull final ILogger logger) { */ @Nonnull @Override - public Builder httpClient(@Nonnull final httpClientType client) { + public Builder httpClient(@Nonnull final httpClientType client) { super.httpClient(client); return this; } @@ -122,7 +139,7 @@ public Builder httpClient(@Nonnull final httpClientType client) */ @Nonnull @Override - public Builder authenticationProvider(@Nonnull final IAuthenticationProvider auth) { + public Builder authenticationProvider(@Nonnull final IAuthenticationProvider auth) { super.authenticationProvider(auth); return this; } diff --git a/test/Typewriter.Test/TestDataJavaBeta/com/microsoft/graph/requests/GraphServiceClient.java b/test/Typewriter.Test/TestDataJavaBeta/com/microsoft/graph/requests/GraphServiceClient.java index d841c80a6..d23a7bea0 100644 --- a/test/Typewriter.Test/TestDataJavaBeta/com/microsoft/graph/requests/GraphServiceClient.java +++ b/test/Typewriter.Test/TestDataJavaBeta/com/microsoft/graph/requests/GraphServiceClient.java @@ -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 type of a request for the native http client */ -public class GraphServiceClient extends BaseClient implements IBaseClient { +public class GraphServiceClient extends BaseClient implements IBaseClient { /** * Restricted constructor */ @@ -51,13 +53,28 @@ public String getServiceSDKVersion() { * @return builder to start configuring the client */ @Nonnull - public static Builder builder() { + public static Builder builder() { + return builder(OkHttpClient.class, Request.class); + } + + /** + * Gets the builder to start configuring the client + * + * @param the type of the native http client + * @param 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 Builder builder(Class nativeClientClass, Class nativeRequestClass) { return new Builder<>(); } /** * Builder to help configure the Graph service client + * @param type of a request for the native http client */ - public static class Builder extends BaseClient.Builder { + public static class Builder extends BaseClient.Builder { /** * Sets the serializer. * @@ -67,7 +84,7 @@ public static class Builder extends BaseClient.Builder serializer(@Nonnull final ISerializer serializer) { + public Builder serializer(@Nonnull final ISerializer serializer) { super.serializer(serializer); return this; } @@ -81,7 +98,7 @@ public Builder serializer(@Nonnull final ISerializer serializer) */ @Nonnull @Override - public Builder httpProvider(@Nonnull final IHttpProvider httpProvider) { + public Builder httpProvider(@Nonnull final IHttpProvider httpProvider) { super.httpProvider(httpProvider); return this; } @@ -95,7 +112,7 @@ public Builder httpProvider(@Nonnull final IHttpProvider httpPro */ @Nonnull @Override - public Builder logger(@Nonnull final ILogger logger) { + public Builder logger(@Nonnull final ILogger logger) { super.logger(logger); return this; } @@ -109,7 +126,7 @@ public Builder logger(@Nonnull final ILogger logger) { */ @Nonnull @Override - public Builder httpClient(@Nonnull final httpClientType client) { + public Builder httpClient(@Nonnull final httpClientType client) { super.httpClient(client); return this; } @@ -122,7 +139,7 @@ public Builder httpClient(@Nonnull final httpClientType client) */ @Nonnull @Override - public Builder authenticationProvider(@Nonnull final IAuthenticationProvider auth) { + public Builder authenticationProvider(@Nonnull final IAuthenticationProvider auth) { super.authenticationProvider(auth); return this; }