From 5a032ae79273334be30794b4aef8a1e1bfd10d58 Mon Sep 17 00:00:00 2001 From: Amar Zavery Date: Thu, 28 Apr 2016 13:38:18 -0700 Subject: [PATCH] remove null check validation for unixtime as they are treated as long in java --- .../java/fixtures/bodyinteger/IntOperations.java | 3 +-- .../java/fixtures/bodyinteger/IntOperationsImpl.java | 12 ++---------- .../src/main/java/fixtures/url/PathsOperations.java | 3 +-- .../main/java/fixtures/url/PathsOperationsImpl.java | 12 ++---------- .../Java/Java/TemplateModels/MethodTemplateModel.cs | 1 + 5 files changed, 7 insertions(+), 24 deletions(-) diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/IntOperations.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/IntOperations.java index 06d2cb2eb7f6c..9710c80eabe31 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/IntOperations.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/IntOperations.java @@ -233,10 +233,9 @@ public interface IntOperations { * @param intBody the long value * @throws ErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the {@link ServiceResponse} object if successful. */ - ServiceResponse putUnixTimeDate(long intBody) throws ErrorException, IOException, IllegalArgumentException; + ServiceResponse putUnixTimeDate(long intBody) throws ErrorException, IOException; /** * Put datetime encoded as Unix time. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/IntOperationsImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/IntOperationsImpl.java index 58cd455e4da17..134ce02e57ae8 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/IntOperationsImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/IntOperationsImpl.java @@ -620,13 +620,9 @@ private ServiceResponse getUnixTimeDelegate(Response respons * @param intBody the long value * @throws ErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the {@link ServiceResponse} object if successful. */ - public ServiceResponse putUnixTimeDate(long intBody) throws ErrorException, IOException, IllegalArgumentException { - if (intBody == null) { - throw new IllegalArgumentException("Parameter intBody is required and cannot be null."); - } + public ServiceResponse putUnixTimeDate(long intBody) throws ErrorException, IOException { Call call = service.putUnixTimeDate(intBody); return putUnixTimeDateDelegate(call.execute()); } @@ -643,10 +639,6 @@ public ServiceCall putUnixTimeDateAsync(long intBody, final ServiceCallback call = service.putUnixTimeDate(intBody); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @@ -662,7 +654,7 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse putUnixTimeDateDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { + private ServiceResponse putUnixTimeDateDelegate(Response response) throws ErrorException, IOException { return new ServiceResponseBuilder(this.client.getMapperAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(ErrorException.class) diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/PathsOperations.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/PathsOperations.java index 6f820294073ca..1ccd08f952b57 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/PathsOperations.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/PathsOperations.java @@ -508,10 +508,9 @@ public interface PathsOperations { * @param unixTimeUrlPath Unix time encoded value * @throws ErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the {@link ServiceResponse} object if successful. */ - ServiceResponse unixTimeUrl(long unixTimeUrlPath) throws ErrorException, IOException, IllegalArgumentException; + ServiceResponse unixTimeUrl(long unixTimeUrlPath) throws ErrorException, IOException; /** * Get the date 2016-04-13 encoded value as '1460505600' (Unix time). diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/PathsOperationsImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/PathsOperationsImpl.java index 60f4ea1452807..31942e3ce28cb 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/PathsOperationsImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/PathsOperationsImpl.java @@ -1428,13 +1428,9 @@ private ServiceResponse arrayCsvInPathDelegate(Response resp * @param unixTimeUrlPath Unix time encoded value * @throws ErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the {@link ServiceResponse} object if successful. */ - public ServiceResponse unixTimeUrl(long unixTimeUrlPath) throws ErrorException, IOException, IllegalArgumentException { - if (unixTimeUrlPath == null) { - throw new IllegalArgumentException("Parameter unixTimeUrlPath is required and cannot be null."); - } + public ServiceResponse unixTimeUrl(long unixTimeUrlPath) throws ErrorException, IOException { Call call = service.unixTimeUrl(unixTimeUrlPath); return unixTimeUrlDelegate(call.execute()); } @@ -1451,10 +1447,6 @@ public ServiceCall unixTimeUrlAsync(long unixTimeUrlPath, final ServiceCallback< if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } - if (unixTimeUrlPath == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter unixTimeUrlPath is required and cannot be null.")); - return null; - } Call call = service.unixTimeUrl(unixTimeUrlPath); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @@ -1470,7 +1462,7 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse unixTimeUrlDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { + private ServiceResponse unixTimeUrlDelegate(Response response) throws ErrorException, IOException { return new ServiceResponseBuilder(this.client.getMapperAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(ErrorException.class) diff --git a/AutoRest/Generators/Java/Java/TemplateModels/MethodTemplateModel.cs b/AutoRest/Generators/Java/Java/TemplateModels/MethodTemplateModel.cs index c9f8bc6faf9fa..7b9afbb821d68 100644 --- a/AutoRest/Generators/Java/Java/TemplateModels/MethodTemplateModel.cs +++ b/AutoRest/Generators/Java/Java/TemplateModels/MethodTemplateModel.cs @@ -363,6 +363,7 @@ public IEnumerable RequiredNullableParameters !param.Type.IsPrimaryType(KnownPrimaryType.Double) && !param.Type.IsPrimaryType(KnownPrimaryType.Boolean) && !param.Type.IsPrimaryType(KnownPrimaryType.Long) && + !param.Type.IsPrimaryType(KnownPrimaryType.UnixTime) && !param.IsConstant && param.IsRequired) { yield return param;