From 2db0bc0bcec5e8286eab42616fbc0ebc9341ef83 Mon Sep 17 00:00:00 2001 From: Mira Leung Date: Wed, 2 Dec 2020 18:31:30 -0800 Subject: [PATCH] [ggj][codegen] fix: replace Objects.isNull() with equality check for Java 7 compat (#583) * fix: fix dep ordering in Bazel dedupe rules * fix: replace Objects.isNull() with equality check for Java 7 compat --- .../composer/BatchingDescriptorComposer.java | 11 ++- .../ResourceNameHelperClassComposer.java | 40 +++-------- .../composer/ServiceClientClassComposer.java | 9 +-- .../ServiceStubSettingsClassComposer.java | 10 +-- .../gapic/composer/goldens/AgentName.golden | 12 ++-- ...DescriptorComposerTestNoSubresponse.golden | 2 +- ...ngDescriptorComposerTestSubresponse.golden | 2 +- .../goldens/BillingAccountLocationName.golden | 10 +-- .../gapic/composer/goldens/EchoClient.golden | 7 +- .../composer/goldens/EchoStubSettings.golden | 5 +- .../gapic/composer/goldens/FoobarName.golden | 16 ++--- .../composer/goldens/IdentityClient.golden | 7 +- .../LoggingServiceV2StubSettings.golden | 9 ++- .../goldens/PublisherStubSettings.golden | 9 ++- .../gapic/composer/goldens/SessionName.golden | 8 +-- .../gapic/composer/goldens/TestName.golden | 12 ++-- .../goldens/asset/AssetServiceClient.java | 7 +- .../asset/AssetServiceStubSettings.java | 5 +- test/integration/goldens/asset/FeedName.java | 16 ++--- .../integration/goldens/library/BookName.java | 10 +-- .../goldens/library/LibraryServiceClient.java | 31 ++++----- .../library/LibraryServiceStubSettings.java | 5 +- .../goldens/library/ShelfName.java | 8 +-- .../logging/BillingAccountLocationName.java | 10 +-- .../goldens/logging/BillingAccountName.java | 8 +-- .../goldens/logging/CmekSettingsName.java | 16 ++--- .../goldens/logging/ConfigClient.java | 67 ++++++++----------- .../logging/ConfigServiceV2StubSettings.java | 7 +- .../goldens/logging/FolderLocationName.java | 10 +-- .../goldens/logging/FolderName.java | 8 +-- .../goldens/logging/LocationName.java | 10 +-- .../goldens/logging/LogBucketName.java | 20 +++--- .../goldens/logging/LogExclusionName.java | 18 ++--- .../goldens/logging/LogMetricName.java | 10 +-- test/integration/goldens/logging/LogName.java | 18 ++--- .../goldens/logging/LogSinkName.java | 18 ++--- .../goldens/logging/LoggingClient.java | 21 ++---- .../logging/LoggingServiceV2StubSettings.java | 9 ++- .../goldens/logging/MetricsClient.java | 11 ++- .../logging/MetricsServiceV2StubSettings.java | 3 +- .../logging/OrganizationLocationName.java | 10 +-- .../goldens/logging/OrganizationName.java | 8 +-- .../goldens/logging/ProjectName.java | 8 +-- .../goldens/redis/CloudRedisClient.java | 17 ++--- .../goldens/redis/CloudRedisStubSettings.java | 3 +- .../goldens/redis/InstanceName.java | 12 ++-- .../goldens/redis/LocationName.java | 10 +-- 47 files changed, 250 insertions(+), 333 deletions(-) diff --git a/src/main/java/com/google/api/generator/gapic/composer/BatchingDescriptorComposer.java b/src/main/java/com/google/api/generator/gapic/composer/BatchingDescriptorComposer.java index 4202809ce1..006f93e248 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/BatchingDescriptorComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/BatchingDescriptorComposer.java @@ -29,8 +29,10 @@ import com.google.api.generator.engine.ast.MethodDefinition; import com.google.api.generator.engine.ast.MethodInvocationExpr; import com.google.api.generator.engine.ast.NewObjectExpr; +import com.google.api.generator.engine.ast.NullObjectValue; import com.google.api.generator.engine.ast.PrimitiveValue; import com.google.api.generator.engine.ast.Reference; +import com.google.api.generator.engine.ast.RelationalOperationExpr; import com.google.api.generator.engine.ast.ScopeNode; import com.google.api.generator.engine.ast.Statement; import com.google.api.generator.engine.ast.TypeNode; @@ -50,7 +52,6 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.stream.Collectors; public class BatchingDescriptorComposer { @@ -203,12 +204,8 @@ private static MethodDefinition createGetRequestBuilderMethod( Arrays.asList( IfStatement.builder() .setConditionExpr( - MethodInvocationExpr.builder() - .setStaticReferenceType(toType(Objects.class)) - .setMethodName("isNull") - .setArguments(builderVarExpr) - .setReturnType(TypeNode.BOOLEAN) - .build()) + RelationalOperationExpr.equalToWithExprs( + builderVarExpr, ValueExpr.withValue(NullObjectValue.create()))) .setBody(Arrays.asList(ExprStatement.withExpr(toBuilderExpr))) .setElseBody(Arrays.asList(ExprStatement.withExpr(addAllExpr))) .build())) diff --git a/src/main/java/com/google/api/generator/gapic/composer/ResourceNameHelperClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ResourceNameHelperClassComposer.java index f49045ad86..cd19fd00ee 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ResourceNameHelperClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ResourceNameHelperClassComposer.java @@ -44,7 +44,6 @@ import com.google.api.generator.engine.ast.ThisObjectValue; import com.google.api.generator.engine.ast.ThrowExpr; import com.google.api.generator.engine.ast.TypeNode; -import com.google.api.generator.engine.ast.UnaryOperationExpr; import com.google.api.generator.engine.ast.ValueExpr; import com.google.api.generator.engine.ast.VaporReference; import com.google.api.generator.engine.ast.Variable; @@ -860,17 +859,13 @@ private static MethodDefinition createToStringListMethod(TypeNode thisClassType) .build()) .build(); - // TODO(miraleung): Use equality check instead of Objects. VariableExpr valueVarExpr = VariableExpr.withVariable( Variable.builder().setName("value").setType(thisClassType).build()); + // We use an equality check instead of Objects.isNull() for Java 7 compatibility. Expr isNullCheck = - MethodInvocationExpr.builder() - .setStaticReferenceType(STATIC_TYPES.get("Objects")) - .setMethodName("isNull") - .setArguments(valueVarExpr) - .setReturnType(TypeNode.BOOLEAN) - .build(); + RelationalOperationExpr.equalToWithExprs( + valueVarExpr, ValueExpr.withValue(NullObjectValue.create())); Statement listAddEmptyStringStatement = ExprStatement.withExpr( MethodInvocationExpr.builder() @@ -1007,13 +1002,8 @@ private static MethodDefinition createGetFieldValuesMapMethod( .setArguments(ValueExpr.withValue(tokenStrVal), tokenVarExpr) .build(); Expr notNullCheckExpr = - UnaryOperationExpr.logicalNotWithExpr( - MethodInvocationExpr.builder() - .setStaticReferenceType(STATIC_TYPES.get("Objects")) - .setMethodName("isNull") - .setArguments(tokenVarExpr) - .setReturnType(TypeNode.BOOLEAN) - .build()); + RelationalOperationExpr.notEqualToWithExprs( + tokenVarExpr, ValueExpr.withValue(NullObjectValue.create())); tokenIfStatements.add( IfStatement.builder() .setConditionExpr(notNullCheckExpr) @@ -1040,14 +1030,9 @@ private static MethodDefinition createGetFieldValuesMapMethod( middleIfBlockStatements.add(ExprStatement.withExpr(fieldValuesMapAssignExpr)); // Middle if-block, i.e. `if (fieldValuesMap == null)`. - // TODO(miraleung): Use eq operator here. - MethodInvocationExpr fieldValuesMapNullCheckExpr = - MethodInvocationExpr.builder() - .setStaticReferenceType(STATIC_TYPES.get("Objects")) - .setMethodName("isNull") - .setArguments(fieldValuesMapVarExpr) - .setReturnType(TypeNode.BOOLEAN) - .build(); + Expr fieldValuesMapNullCheckExpr = + RelationalOperationExpr.equalToWithExprs( + fieldValuesMapVarExpr, ValueExpr.withValue(NullObjectValue.create())); IfStatement fieldValuesMapIfStatement = IfStatement.builder() .setConditionExpr(fieldValuesMapNullCheckExpr) @@ -1140,13 +1125,8 @@ private static MethodDefinition createToStringMethod( VariableExpr fixedValueVarExpr = FIXED_CLASS_VARS.get("fixedValue"); // Code: return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()) Expr fixedValueNullCheck = - UnaryOperationExpr.logicalNotWithExpr( - MethodInvocationExpr.builder() - .setStaticReferenceType(STATIC_TYPES.get("Objects")) - .setMethodName("isNull") - .setArguments(fixedValueVarExpr) - .setReturnType(TypeNode.BOOLEAN) - .build()); + RelationalOperationExpr.notEqualToWithExprs( + fixedValueVarExpr, ValueExpr.withValue(NullObjectValue.create())); MethodInvocationExpr instantiateExpr = MethodInvocationExpr.builder() diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java index 5f6a00f4d8..23b3b5e1d7 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java @@ -44,6 +44,7 @@ import com.google.api.generator.engine.ast.PrimitiveValue; import com.google.api.generator.engine.ast.Reference; import com.google.api.generator.engine.ast.ReferenceConstructorExpr; +import com.google.api.generator.engine.ast.RelationalOperationExpr; import com.google.api.generator.engine.ast.ScopeNode; import com.google.api.generator.engine.ast.Statement; import com.google.api.generator.engine.ast.SuperObjectValue; @@ -1347,14 +1348,8 @@ static MethodInvocationExpr buildNestedSetterInvocationExpr( VariableExpr.withVariable( Variable.builder().setName(argumentName).setType(argumentType).build()); if (argument.isResourceNameHelper()) { - MethodInvocationExpr isNullCheckExpr = - MethodInvocationExpr.builder() - .setStaticReferenceType(OBJECTS_TYPE) - .setMethodName("isNull") - .setArguments(Arrays.asList(argVarExpr)) - .setReturnType(TypeNode.BOOLEAN) - .build(); Expr nullExpr = ValueExpr.withValue(NullObjectValue.create()); + Expr isNullCheckExpr = RelationalOperationExpr.equalToWithExprs(argVarExpr, nullExpr); MethodInvocationExpr toStringExpr = MethodInvocationExpr.builder() .setExprReferenceExpr(argVarExpr) diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceStubSettingsClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceStubSettingsClassComposer.java index 166cc24573..cfb4a0df55 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceStubSettingsClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceStubSettingsClassComposer.java @@ -68,6 +68,7 @@ import com.google.api.generator.engine.ast.NullObjectValue; import com.google.api.generator.engine.ast.Reference; import com.google.api.generator.engine.ast.ReferenceConstructorExpr; +import com.google.api.generator.engine.ast.RelationalOperationExpr; import com.google.api.generator.engine.ast.ReturnExpr; import com.google.api.generator.engine.ast.ScopeNode; import com.google.api.generator.engine.ast.Statement; @@ -545,13 +546,8 @@ private static Expr createPagedListDescriptorAssignExpr( .setReturnType(returnType) .build(); Expr conditionExpr = - MethodInvocationExpr.builder() - .setStaticReferenceType( - TypeNode.withReference(ConcreteReference.withClazz(Objects.class))) - .setMethodName("isNull") - .setArguments(getResponsesListExpr) - .setReturnType(TypeNode.BOOLEAN) - .build(); + RelationalOperationExpr.equalToWithExprs( + getResponsesListExpr, ValueExpr.withValue(NullObjectValue.create())); Expr thenExpr = MethodInvocationExpr.builder() .setStaticReferenceType( diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/AgentName.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/AgentName.golden index c722cdd4f7..595151d8c1 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/AgentName.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/AgentName.golden @@ -122,7 +122,7 @@ public class AgentName implements ResourceName { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (AgentName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -137,14 +137,14 @@ public class AgentName implements ResourceName { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(project)) { + if (project != null) { fieldMapBuilder.put("project", project); } - if (!Objects.isNull(location)) { + if (location != null) { fieldMapBuilder.put("location", location); } fieldValuesMap = fieldMapBuilder.build(); @@ -160,7 +160,7 @@ public class AgentName implements ResourceName { @Override public String toString() { - return !Objects.isNull(fixedValue) ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } @Override diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/BatchingDescriptorComposerTestNoSubresponse.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/BatchingDescriptorComposerTestNoSubresponse.golden index b9c9eba122..e66aeedf3c 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/BatchingDescriptorComposerTestNoSubresponse.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/BatchingDescriptorComposerTestNoSubresponse.golden @@ -10,7 +10,7 @@ return new RequestBuilder() { private WriteLogEntriesRequest.Builder builder; @Override public void appendRequest(WriteLogEntriesRequest request) { -if (Objects.isNull(builder)) { +if (builder == null) { builder = request.toBuilder(); } else { builder.addAllEntries(request.getEntriesList()); diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/BatchingDescriptorComposerTestSubresponse.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/BatchingDescriptorComposerTestSubresponse.golden index a322c69aec..7cba370e75 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/BatchingDescriptorComposerTestSubresponse.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/BatchingDescriptorComposerTestSubresponse.golden @@ -10,7 +10,7 @@ return new RequestBuilder() { private PublishRequest.Builder builder; @Override public void appendRequest(PublishRequest request) { -if (Objects.isNull(builder)) { +if (builder == null) { builder = request.toBuilder(); } else { builder.addAllMessages(request.getMessagesList()); diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/BillingAccountLocationName.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/BillingAccountLocationName.golden index 7500be4b9d..ba8efd9eb6 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/BillingAccountLocationName.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/BillingAccountLocationName.golden @@ -77,7 +77,7 @@ public class BillingAccountLocationName implements ResourceName { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (BillingAccountLocationName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -92,14 +92,14 @@ public class BillingAccountLocationName implements ResourceName { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(billingAccount)) { + if (billingAccount != null) { fieldMapBuilder.put("billing_account", billingAccount); } - if (!Objects.isNull(location)) { + if (location != null) { fieldMapBuilder.put("location", location); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden index c4745c9892..45cfef387a 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden @@ -26,7 +26,6 @@ import com.google.showcase.v1beta1.stub.EchoStub; import com.google.showcase.v1beta1.stub.EchoStubSettings; import java.io.IOException; import java.util.List; -import java.util.Objects; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -160,9 +159,7 @@ public class EchoClient implements BackgroundResource { */ public final EchoResponse echo(ResourceName parent) { EchoRequest request = - EchoRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) - .build(); + EchoRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); return echo(request); } @@ -183,7 +180,7 @@ public class EchoClient implements BackgroundResource { */ public final EchoResponse echo(FoobarName name) { EchoRequest request = - EchoRequest.newBuilder().setName(Objects.isNull(name) ? null : name.toString()).build(); + EchoRequest.newBuilder().setName(name == null ? null : name.toString()).build(); return echo(request); } diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoStubSettings.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoStubSettings.golden index bd4d6aa083..df88bb4b31 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoStubSettings.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoStubSettings.golden @@ -48,7 +48,6 @@ import com.google.showcase.v1beta1.WaitRequest; import com.google.showcase.v1beta1.WaitResponse; import java.io.IOException; import java.util.List; -import java.util.Objects; import javax.annotation.Generated; import org.threeten.bp.Duration; @@ -135,7 +134,7 @@ public class EchoStubSettings extends StubSettings { @Override public Iterable extractResources(PagedExpandResponse payload) { - return Objects.isNull(payload.getResponsesList()) + return payload.getResponsesList() == null ? ImmutableList.of() : payload.getResponsesList(); } @@ -171,7 +170,7 @@ public class EchoStubSettings extends StubSettings { @Override public Iterable extractResources(PagedExpandResponse payload) { - return Objects.isNull(payload.getResponsesList()) + return payload.getResponsesList() == null ? ImmutableList.of() : payload.getResponsesList(); } diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/FoobarName.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/FoobarName.golden index 9823f297c5..f9b1fe01e3 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/FoobarName.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/FoobarName.golden @@ -207,7 +207,7 @@ public class FoobarName implements ResourceName { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (FoobarName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -225,20 +225,20 @@ public class FoobarName implements ResourceName { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(project)) { + if (project != null) { fieldMapBuilder.put("project", project); } - if (!Objects.isNull(foobar)) { + if (foobar != null) { fieldMapBuilder.put("foobar", foobar); } - if (!Objects.isNull(variant)) { + if (variant != null) { fieldMapBuilder.put("variant", variant); } - if (!Objects.isNull(barFoo)) { + if (barFoo != null) { fieldMapBuilder.put("bar_foo", barFoo); } fieldValuesMap = fieldMapBuilder.build(); @@ -254,7 +254,7 @@ public class FoobarName implements ResourceName { @Override public String toString() { - return !Objects.isNull(fixedValue) ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } @Override diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden index 091e335eee..db54847763 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden @@ -16,7 +16,6 @@ import com.google.showcase.v1beta1.stub.IdentityStub; import com.google.showcase.v1beta1.stub.IdentityStubSettings; import java.io.IOException; import java.util.List; -import java.util.Objects; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -194,7 +193,7 @@ public class IdentityClient implements BackgroundResource { */ public final User getUser(UserName name) { GetUserRequest request = - GetUserRequest.newBuilder().setName(Objects.isNull(name) ? null : name.toString()).build(); + GetUserRequest.newBuilder().setName(name == null ? null : name.toString()).build(); return getUser(request); } @@ -245,9 +244,7 @@ public class IdentityClient implements BackgroundResource { */ public final void deleteUser(UserName name) { DeleteUserRequest request = - DeleteUserRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) - .build(); + DeleteUserRequest.newBuilder().setName(name == null ? null : name.toString()).build(); deleteUser(request); } diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/LoggingServiceV2StubSettings.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/LoggingServiceV2StubSettings.golden index ef336d4033..e4f242d816 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/LoggingServiceV2StubSettings.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/LoggingServiceV2StubSettings.golden @@ -53,7 +53,6 @@ import com.google.protobuf.Empty; import java.io.IOException; import java.util.Collection; import java.util.List; -import java.util.Objects; import javax.annotation.Generated; import org.threeten.bp.Duration; @@ -147,7 +146,7 @@ public class LoggingServiceV2StubSettings extends StubSettings extractResources(ListLogEntriesResponse payload) { - return Objects.isNull(payload.getEntriesList()) + return payload.getEntriesList() == null ? ImmutableList.of() : payload.getEntriesList(); } @@ -196,7 +195,7 @@ public class LoggingServiceV2StubSettings extends StubSettings extractResources( ListMonitoredResourceDescriptorsResponse payload) { - return Objects.isNull(payload.getResourceDescriptorsList()) + return payload.getResourceDescriptorsList() == null ? ImmutableList.of() : payload.getResourceDescriptorsList(); } @@ -232,7 +231,7 @@ public class LoggingServiceV2StubSettings extends StubSettings extractResources(ListLogsResponse payload) { - return Objects.isNull(payload.getLogNamesList()) + return payload.getLogNamesList() == null ? ImmutableList.of() : payload.getLogNamesList(); } @@ -320,7 +319,7 @@ public class LoggingServiceV2StubSettings extends StubSettings { @Override public Iterable extractResources(ListTopicsResponse payload) { - return Objects.isNull(payload.getTopicsList()) + return payload.getTopicsList() == null ? ImmutableList.of() : payload.getTopicsList(); } @@ -192,7 +191,7 @@ public class PublisherStubSettings extends StubSettings { @Override public Iterable extractResources(ListTopicSubscriptionsResponse payload) { - return Objects.isNull(payload.getSubscriptionsList()) + return payload.getSubscriptionsList() == null ? ImmutableList.of() : payload.getSubscriptionsList(); } @@ -231,7 +230,7 @@ public class PublisherStubSettings extends StubSettings { @Override public Iterable extractResources(ListTopicSnapshotsResponse payload) { - return Objects.isNull(payload.getSnapshotsList()) + return payload.getSnapshotsList() == null ? ImmutableList.of() : payload.getSnapshotsList(); } @@ -313,7 +312,7 @@ public class PublisherStubSettings extends StubSettings { @Override public void appendRequest(PublishRequest request) { - if (Objects.isNull(builder)) { + if (builder == null) { builder = request.toBuilder(); } else { builder.addAllMessages(request.getMessagesList()); diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/SessionName.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/SessionName.golden index e0ef56bae0..82ed52244b 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/SessionName.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/SessionName.golden @@ -68,7 +68,7 @@ public class SessionName implements ResourceName { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (SessionName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -83,11 +83,11 @@ public class SessionName implements ResourceName { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(session)) { + if (session != null) { fieldMapBuilder.put("session", session); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/TestName.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/TestName.golden index af723a66c3..5f99dac9ee 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/TestName.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/TestName.golden @@ -87,7 +87,7 @@ public class TestName implements ResourceName { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (TestName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -102,17 +102,17 @@ public class TestName implements ResourceName { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(session)) { + if (session != null) { fieldMapBuilder.put("session", session); } - if (!Objects.isNull(shardId)) { + if (shardId != null) { fieldMapBuilder.put("shard_id", shardId); } - if (!Objects.isNull(testId)) { + if (testId != null) { fieldMapBuilder.put("test_id", testId); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/test/integration/goldens/asset/AssetServiceClient.java b/test/integration/goldens/asset/AssetServiceClient.java index dad79b7391..2ade6c30d5 100644 --- a/test/integration/goldens/asset/AssetServiceClient.java +++ b/test/integration/goldens/asset/AssetServiceClient.java @@ -36,7 +36,6 @@ import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; -import java.util.Objects; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -289,7 +288,7 @@ public final UnaryCallable createFeedCallable() { */ public final Feed getFeed(FeedName name) { GetFeedRequest request = - GetFeedRequest.newBuilder().setName(Objects.isNull(name) ? null : name.toString()).build(); + GetFeedRequest.newBuilder().setName(name == null ? null : name.toString()).build(); return getFeed(request); } @@ -409,9 +408,7 @@ public final UnaryCallable updateFeedCallable() { */ public final void deleteFeed(FeedName name) { DeleteFeedRequest request = - DeleteFeedRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) - .build(); + DeleteFeedRequest.newBuilder().setName(name == null ? null : name.toString()).build(); deleteFeed(request); } diff --git a/test/integration/goldens/asset/AssetServiceStubSettings.java b/test/integration/goldens/asset/AssetServiceStubSettings.java index a86ad5dbdc..055e09dea5 100644 --- a/test/integration/goldens/asset/AssetServiceStubSettings.java +++ b/test/integration/goldens/asset/AssetServiceStubSettings.java @@ -70,7 +70,6 @@ import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; -import java.util.Objects; import javax.annotation.Generated; import org.threeten.bp.Duration; @@ -168,7 +167,7 @@ public String extractNextToken(SearchAllResourcesResponse payload) { @Override public Iterable extractResources( SearchAllResourcesResponse payload) { - return Objects.isNull(payload.getResultsList()) + return payload.getResultsList() == null ? ImmutableList.of() : payload.getResultsList(); } @@ -209,7 +208,7 @@ public String extractNextToken(SearchAllIamPoliciesResponse payload) { @Override public Iterable extractResources( SearchAllIamPoliciesResponse payload) { - return Objects.isNull(payload.getResultsList()) + return payload.getResultsList() == null ? ImmutableList.of() : payload.getResultsList(); } diff --git a/test/integration/goldens/asset/FeedName.java b/test/integration/goldens/asset/FeedName.java index 3d76da97b4..b9e600c37d 100644 --- a/test/integration/goldens/asset/FeedName.java +++ b/test/integration/goldens/asset/FeedName.java @@ -186,7 +186,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (FeedName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -203,20 +203,20 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(project)) { + if (project != null) { fieldMapBuilder.put("project", project); } - if (!Objects.isNull(feed)) { + if (feed != null) { fieldMapBuilder.put("feed", feed); } - if (!Objects.isNull(folder)) { + if (folder != null) { fieldMapBuilder.put("folder", folder); } - if (!Objects.isNull(organization)) { + if (organization != null) { fieldMapBuilder.put("organization", organization); } fieldValuesMap = fieldMapBuilder.build(); @@ -232,7 +232,7 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return !Objects.isNull(fixedValue) ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } @Override diff --git a/test/integration/goldens/library/BookName.java b/test/integration/goldens/library/BookName.java index eb89e75b61..ac4db32a0b 100644 --- a/test/integration/goldens/library/BookName.java +++ b/test/integration/goldens/library/BookName.java @@ -91,7 +91,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (BookName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -106,14 +106,14 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(shelfId)) { + if (shelfId != null) { fieldMapBuilder.put("shelf_id", shelfId); } - if (!Objects.isNull(bookId)) { + if (bookId != null) { fieldMapBuilder.put("book_id", bookId); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/test/integration/goldens/library/LibraryServiceClient.java b/test/integration/goldens/library/LibraryServiceClient.java index e9d2780f0b..033e0b3b3d 100644 --- a/test/integration/goldens/library/LibraryServiceClient.java +++ b/test/integration/goldens/library/LibraryServiceClient.java @@ -49,7 +49,6 @@ import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; -import java.util.Objects; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -209,7 +208,7 @@ public final UnaryCallable createShelfCallable() { */ public final Shelf getShelf(ShelfName name) { GetShelfRequest request = - GetShelfRequest.newBuilder().setName(Objects.isNull(name) ? null : name.toString()).build(); + GetShelfRequest.newBuilder().setName(name == null ? null : name.toString()).build(); return getShelf(request); } @@ -290,9 +289,7 @@ public final UnaryCallable listShelvesC */ public final void deleteShelf(ShelfName name) { DeleteShelfRequest request = - DeleteShelfRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) - .build(); + DeleteShelfRequest.newBuilder().setName(name == null ? null : name.toString()).build(); deleteShelf(request); } @@ -345,8 +342,8 @@ public final UnaryCallable deleteShelfCallable() { public final Shelf mergeShelves(ShelfName name, ShelfName otherShelfName) { MergeShelvesRequest request = MergeShelvesRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) - .setOtherShelfName(Objects.isNull(otherShelfName) ? null : otherShelfName.toString()) + .setName(name == null ? null : name.toString()) + .setOtherShelfName(otherShelfName == null ? null : otherShelfName.toString()) .build(); return mergeShelves(request); } @@ -367,7 +364,7 @@ public final Shelf mergeShelves(ShelfName name, ShelfName otherShelfName) { public final Shelf mergeShelves(ShelfName name, String otherShelfName) { MergeShelvesRequest request = MergeShelvesRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) + .setName(name == null ? null : name.toString()) .setOtherShelfName(otherShelfName) .build(); return mergeShelves(request); @@ -390,7 +387,7 @@ public final Shelf mergeShelves(String name, ShelfName otherShelfName) { MergeShelvesRequest request = MergeShelvesRequest.newBuilder() .setName(name) - .setOtherShelfName(Objects.isNull(otherShelfName) ? null : otherShelfName.toString()) + .setOtherShelfName(otherShelfName == null ? null : otherShelfName.toString()) .build(); return mergeShelves(request); } @@ -456,7 +453,7 @@ public final UnaryCallable mergeShelvesCallable() { public final Book createBook(ShelfName name, Book book) { CreateBookRequest request = CreateBookRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) + .setName(name == null ? null : name.toString()) .setBook(book) .build(); return createBook(request); @@ -505,7 +502,7 @@ public final UnaryCallable createBookCallable() { */ public final Book getBook(BookName name) { GetBookRequest request = - GetBookRequest.newBuilder().setName(Objects.isNull(name) ? null : name.toString()).build(); + GetBookRequest.newBuilder().setName(name == null ? null : name.toString()).build(); return getBook(request); } @@ -553,9 +550,7 @@ public final UnaryCallable getBookCallable() { */ public final ListBooksPagedResponse listBooks(ShelfName name) { ListBooksRequest request = - ListBooksRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) - .build(); + ListBooksRequest.newBuilder().setName(name == null ? null : name.toString()).build(); return listBooks(request); } @@ -679,8 +674,8 @@ public final UnaryCallable updateBookCallable() { public final Book moveBook(BookName name, ShelfName otherShelfName) { MoveBookRequest request = MoveBookRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) - .setOtherShelfName(Objects.isNull(otherShelfName) ? null : otherShelfName.toString()) + .setName(name == null ? null : name.toString()) + .setOtherShelfName(otherShelfName == null ? null : otherShelfName.toString()) .build(); return moveBook(request); } @@ -697,7 +692,7 @@ public final Book moveBook(BookName name, ShelfName otherShelfName) { public final Book moveBook(BookName name, String otherShelfName) { MoveBookRequest request = MoveBookRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) + .setName(name == null ? null : name.toString()) .setOtherShelfName(otherShelfName) .build(); return moveBook(request); @@ -716,7 +711,7 @@ public final Book moveBook(String name, ShelfName otherShelfName) { MoveBookRequest request = MoveBookRequest.newBuilder() .setName(name) - .setOtherShelfName(Objects.isNull(otherShelfName) ? null : otherShelfName.toString()) + .setOtherShelfName(otherShelfName == null ? null : otherShelfName.toString()) .build(); return moveBook(request); } diff --git a/test/integration/goldens/library/LibraryServiceStubSettings.java b/test/integration/goldens/library/LibraryServiceStubSettings.java index 59c8e8aa5f..bc16111efe 100644 --- a/test/integration/goldens/library/LibraryServiceStubSettings.java +++ b/test/integration/goldens/library/LibraryServiceStubSettings.java @@ -63,7 +63,6 @@ import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; -import java.util.Objects; import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS. @@ -150,7 +149,7 @@ public String extractNextToken(ListShelvesResponse payload) { @Override public Iterable extractResources(ListShelvesResponse payload) { - return Objects.isNull(payload.getShelvesList()) + return payload.getShelvesList() == null ? ImmutableList.of() : payload.getShelvesList(); } @@ -186,7 +185,7 @@ public String extractNextToken(ListBooksResponse payload) { @Override public Iterable extractResources(ListBooksResponse payload) { - return Objects.isNull(payload.getBooksList()) + return payload.getBooksList() == null ? ImmutableList.of() : payload.getBooksList(); } diff --git a/test/integration/goldens/library/ShelfName.java b/test/integration/goldens/library/ShelfName.java index cc50ef5f07..d30fb7ec20 100644 --- a/test/integration/goldens/library/ShelfName.java +++ b/test/integration/goldens/library/ShelfName.java @@ -84,7 +84,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (ShelfName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -99,11 +99,11 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(shelfId)) { + if (shelfId != null) { fieldMapBuilder.put("shelf_id", shelfId); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/test/integration/goldens/logging/BillingAccountLocationName.java b/test/integration/goldens/logging/BillingAccountLocationName.java index deaf554a9f..c2be0c8fd9 100644 --- a/test/integration/goldens/logging/BillingAccountLocationName.java +++ b/test/integration/goldens/logging/BillingAccountLocationName.java @@ -93,7 +93,7 @@ public static List parseList(List formattedS public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (BillingAccountLocationName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -108,14 +108,14 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(billingAccount)) { + if (billingAccount != null) { fieldMapBuilder.put("billing_account", billingAccount); } - if (!Objects.isNull(location)) { + if (location != null) { fieldMapBuilder.put("location", location); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/test/integration/goldens/logging/BillingAccountName.java b/test/integration/goldens/logging/BillingAccountName.java index d9667ac9c6..d24f9a77db 100644 --- a/test/integration/goldens/logging/BillingAccountName.java +++ b/test/integration/goldens/logging/BillingAccountName.java @@ -84,7 +84,7 @@ public static List parseList(List formattedStrings) public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (BillingAccountName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -99,11 +99,11 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(billingAccount)) { + if (billingAccount != null) { fieldMapBuilder.put("billing_account", billingAccount); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/test/integration/goldens/logging/CmekSettingsName.java b/test/integration/goldens/logging/CmekSettingsName.java index a3125e93e9..49c925c26d 100644 --- a/test/integration/goldens/logging/CmekSettingsName.java +++ b/test/integration/goldens/logging/CmekSettingsName.java @@ -210,7 +210,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (CmekSettingsName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -228,20 +228,20 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(project)) { + if (project != null) { fieldMapBuilder.put("project", project); } - if (!Objects.isNull(organization)) { + if (organization != null) { fieldMapBuilder.put("organization", organization); } - if (!Objects.isNull(folder)) { + if (folder != null) { fieldMapBuilder.put("folder", folder); } - if (!Objects.isNull(billingAccount)) { + if (billingAccount != null) { fieldMapBuilder.put("billing_account", billingAccount); } fieldValuesMap = fieldMapBuilder.build(); @@ -257,7 +257,7 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return !Objects.isNull(fixedValue) ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } @Override diff --git a/test/integration/goldens/logging/ConfigClient.java b/test/integration/goldens/logging/ConfigClient.java index 14f8749dc1..507ea5ed4a 100644 --- a/test/integration/goldens/logging/ConfigClient.java +++ b/test/integration/goldens/logging/ConfigClient.java @@ -65,7 +65,6 @@ import com.google.protobuf.FieldMask; import java.io.IOException; import java.util.List; -import java.util.Objects; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -189,7 +188,7 @@ public ConfigServiceV2Stub getStub() { public final ListBucketsPagedResponse listBuckets(BillingAccountLocationName parent) { ListBucketsRequest request = ListBucketsRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .build(); return listBuckets(request); } @@ -210,7 +209,7 @@ public final ListBucketsPagedResponse listBuckets(BillingAccountLocationName par public final ListBucketsPagedResponse listBuckets(FolderLocationName parent) { ListBucketsRequest request = ListBucketsRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .build(); return listBuckets(request); } @@ -231,7 +230,7 @@ public final ListBucketsPagedResponse listBuckets(FolderLocationName parent) { public final ListBucketsPagedResponse listBuckets(LocationName parent) { ListBucketsRequest request = ListBucketsRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .build(); return listBuckets(request); } @@ -252,7 +251,7 @@ public final ListBucketsPagedResponse listBuckets(LocationName parent) { public final ListBucketsPagedResponse listBuckets(OrganizationLocationName parent) { ListBucketsRequest request = ListBucketsRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .build(); return listBuckets(request); } @@ -378,9 +377,7 @@ public final UnaryCallable updateBucketCallable( */ public final ListSinksPagedResponse listSinks(BillingAccountName parent) { ListSinksRequest request = - ListSinksRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) - .build(); + ListSinksRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); return listSinks(request); } @@ -395,9 +392,7 @@ public final ListSinksPagedResponse listSinks(BillingAccountName parent) { */ public final ListSinksPagedResponse listSinks(FolderName parent) { ListSinksRequest request = - ListSinksRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) - .build(); + ListSinksRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); return listSinks(request); } @@ -412,9 +407,7 @@ public final ListSinksPagedResponse listSinks(FolderName parent) { */ public final ListSinksPagedResponse listSinks(OrganizationName parent) { ListSinksRequest request = - ListSinksRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) - .build(); + ListSinksRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); return listSinks(request); } @@ -429,9 +422,7 @@ public final ListSinksPagedResponse listSinks(OrganizationName parent) { */ public final ListSinksPagedResponse listSinks(ProjectName parent) { ListSinksRequest request = - ListSinksRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) - .build(); + ListSinksRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); return listSinks(request); } @@ -495,7 +486,7 @@ public final UnaryCallable listSinksCallabl public final LogSink getSink(LogSinkName sinkName) { GetSinkRequest request = GetSinkRequest.newBuilder() - .setSinkName(Objects.isNull(sinkName) ? null : sinkName.toString()) + .setSinkName(sinkName == null ? null : sinkName.toString()) .build(); return getSink(request); } @@ -556,7 +547,7 @@ public final UnaryCallable getSinkCallable() { public final LogSink createSink(BillingAccountName parent, LogSink sink) { CreateSinkRequest request = CreateSinkRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .setSink(sink) .build(); return createSink(request); @@ -580,7 +571,7 @@ public final LogSink createSink(BillingAccountName parent, LogSink sink) { public final LogSink createSink(FolderName parent, LogSink sink) { CreateSinkRequest request = CreateSinkRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .setSink(sink) .build(); return createSink(request); @@ -604,7 +595,7 @@ public final LogSink createSink(FolderName parent, LogSink sink) { public final LogSink createSink(OrganizationName parent, LogSink sink) { CreateSinkRequest request = CreateSinkRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .setSink(sink) .build(); return createSink(request); @@ -628,7 +619,7 @@ public final LogSink createSink(OrganizationName parent, LogSink sink) { public final LogSink createSink(ProjectName parent, LogSink sink) { CreateSinkRequest request = CreateSinkRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .setSink(sink) .build(); return createSink(request); @@ -704,7 +695,7 @@ public final UnaryCallable createSinkCallable() { public final LogSink updateSink(LogSinkName sinkName, LogSink sink) { UpdateSinkRequest request = UpdateSinkRequest.newBuilder() - .setSinkName(Objects.isNull(sinkName) ? null : sinkName.toString()) + .setSinkName(sinkName == null ? null : sinkName.toString()) .setSink(sink) .build(); return updateSink(request); @@ -766,7 +757,7 @@ public final LogSink updateSink(String sinkName, LogSink sink) { public final LogSink updateSink(LogSinkName sinkName, LogSink sink, FieldMask updateMask) { UpdateSinkRequest request = UpdateSinkRequest.newBuilder() - .setSinkName(Objects.isNull(sinkName) ? null : sinkName.toString()) + .setSinkName(sinkName == null ? null : sinkName.toString()) .setSink(sink) .setUpdateMask(updateMask) .build(); @@ -857,7 +848,7 @@ public final UnaryCallable updateSinkCallable() { public final void deleteSink(LogSinkName sinkName) { DeleteSinkRequest request = DeleteSinkRequest.newBuilder() - .setSinkName(Objects.isNull(sinkName) ? null : sinkName.toString()) + .setSinkName(sinkName == null ? null : sinkName.toString()) .build(); deleteSink(request); } @@ -916,7 +907,7 @@ public final UnaryCallable deleteSinkCallable() { public final ListExclusionsPagedResponse listExclusions(BillingAccountName parent) { ListExclusionsRequest request = ListExclusionsRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .build(); return listExclusions(request); } @@ -933,7 +924,7 @@ public final ListExclusionsPagedResponse listExclusions(BillingAccountName paren public final ListExclusionsPagedResponse listExclusions(FolderName parent) { ListExclusionsRequest request = ListExclusionsRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .build(); return listExclusions(request); } @@ -950,7 +941,7 @@ public final ListExclusionsPagedResponse listExclusions(FolderName parent) { public final ListExclusionsPagedResponse listExclusions(OrganizationName parent) { ListExclusionsRequest request = ListExclusionsRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .build(); return listExclusions(request); } @@ -967,7 +958,7 @@ public final ListExclusionsPagedResponse listExclusions(OrganizationName parent) public final ListExclusionsPagedResponse listExclusions(ProjectName parent) { ListExclusionsRequest request = ListExclusionsRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .build(); return listExclusions(request); } @@ -1033,9 +1024,7 @@ public final ListExclusionsPagedResponse listExclusions(ListExclusionsRequest re */ public final LogExclusion getExclusion(LogExclusionName name) { GetExclusionRequest request = - GetExclusionRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) - .build(); + GetExclusionRequest.newBuilder().setName(name == null ? null : name.toString()).build(); return getExclusion(request); } @@ -1093,7 +1082,7 @@ public final UnaryCallable getExclusionCallab public final LogExclusion createExclusion(BillingAccountName parent, LogExclusion exclusion) { CreateExclusionRequest request = CreateExclusionRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .setExclusion(exclusion) .build(); return createExclusion(request); @@ -1115,7 +1104,7 @@ public final LogExclusion createExclusion(BillingAccountName parent, LogExclusio public final LogExclusion createExclusion(FolderName parent, LogExclusion exclusion) { CreateExclusionRequest request = CreateExclusionRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .setExclusion(exclusion) .build(); return createExclusion(request); @@ -1137,7 +1126,7 @@ public final LogExclusion createExclusion(FolderName parent, LogExclusion exclus public final LogExclusion createExclusion(OrganizationName parent, LogExclusion exclusion) { CreateExclusionRequest request = CreateExclusionRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .setExclusion(exclusion) .build(); return createExclusion(request); @@ -1159,7 +1148,7 @@ public final LogExclusion createExclusion(OrganizationName parent, LogExclusion public final LogExclusion createExclusion(ProjectName parent, LogExclusion exclusion) { CreateExclusionRequest request = CreateExclusionRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .setExclusion(exclusion) .build(); return createExclusion(request); @@ -1231,7 +1220,7 @@ public final LogExclusion updateExclusion( LogExclusionName name, LogExclusion exclusion, FieldMask updateMask) { UpdateExclusionRequest request = UpdateExclusionRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) + .setName(name == null ? null : name.toString()) .setExclusion(exclusion) .setUpdateMask(updateMask) .build(); @@ -1304,9 +1293,7 @@ public final UnaryCallable updateExclusion */ public final void deleteExclusion(LogExclusionName name) { DeleteExclusionRequest request = - DeleteExclusionRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) - .build(); + DeleteExclusionRequest.newBuilder().setName(name == null ? null : name.toString()).build(); deleteExclusion(request); } diff --git a/test/integration/goldens/logging/ConfigServiceV2StubSettings.java b/test/integration/goldens/logging/ConfigServiceV2StubSettings.java index c6b37058a0..82472fa977 100644 --- a/test/integration/goldens/logging/ConfigServiceV2StubSettings.java +++ b/test/integration/goldens/logging/ConfigServiceV2StubSettings.java @@ -71,7 +71,6 @@ import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; -import java.util.Objects; import javax.annotation.Generated; import org.threeten.bp.Duration; @@ -170,7 +169,7 @@ public String extractNextToken(ListBucketsResponse payload) { @Override public Iterable extractResources(ListBucketsResponse payload) { - return Objects.isNull(payload.getBucketsList()) + return payload.getBucketsList() == null ? ImmutableList.of() : payload.getBucketsList(); } @@ -206,7 +205,7 @@ public String extractNextToken(ListSinksResponse payload) { @Override public Iterable extractResources(ListSinksResponse payload) { - return Objects.isNull(payload.getSinksList()) + return payload.getSinksList() == null ? ImmutableList.of() : payload.getSinksList(); } @@ -244,7 +243,7 @@ public String extractNextToken(ListExclusionsResponse payload) { @Override public Iterable extractResources(ListExclusionsResponse payload) { - return Objects.isNull(payload.getExclusionsList()) + return payload.getExclusionsList() == null ? ImmutableList.of() : payload.getExclusionsList(); } diff --git a/test/integration/goldens/logging/FolderLocationName.java b/test/integration/goldens/logging/FolderLocationName.java index afde415244..9f31df5554 100644 --- a/test/integration/goldens/logging/FolderLocationName.java +++ b/test/integration/goldens/logging/FolderLocationName.java @@ -91,7 +91,7 @@ public static List parseList(List formattedStrings) public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (FolderLocationName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -106,14 +106,14 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(folder)) { + if (folder != null) { fieldMapBuilder.put("folder", folder); } - if (!Objects.isNull(location)) { + if (location != null) { fieldMapBuilder.put("location", location); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/test/integration/goldens/logging/FolderName.java b/test/integration/goldens/logging/FolderName.java index 20940167a0..8c5790ddef 100644 --- a/test/integration/goldens/logging/FolderName.java +++ b/test/integration/goldens/logging/FolderName.java @@ -84,7 +84,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (FolderName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -99,11 +99,11 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(folder)) { + if (folder != null) { fieldMapBuilder.put("folder", folder); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/test/integration/goldens/logging/LocationName.java b/test/integration/goldens/logging/LocationName.java index ab2a8319ea..468a995a8c 100644 --- a/test/integration/goldens/logging/LocationName.java +++ b/test/integration/goldens/logging/LocationName.java @@ -91,7 +91,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (LocationName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -106,14 +106,14 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(project)) { + if (project != null) { fieldMapBuilder.put("project", project); } - if (!Objects.isNull(location)) { + if (location != null) { fieldMapBuilder.put("location", location); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/test/integration/goldens/logging/LogBucketName.java b/test/integration/goldens/logging/LogBucketName.java index 32d0b934c4..c21d17f977 100644 --- a/test/integration/goldens/logging/LogBucketName.java +++ b/test/integration/goldens/logging/LogBucketName.java @@ -283,7 +283,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (LogBucketName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -301,26 +301,26 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(project)) { + if (project != null) { fieldMapBuilder.put("project", project); } - if (!Objects.isNull(location)) { + if (location != null) { fieldMapBuilder.put("location", location); } - if (!Objects.isNull(bucket)) { + if (bucket != null) { fieldMapBuilder.put("bucket", bucket); } - if (!Objects.isNull(organization)) { + if (organization != null) { fieldMapBuilder.put("organization", organization); } - if (!Objects.isNull(folder)) { + if (folder != null) { fieldMapBuilder.put("folder", folder); } - if (!Objects.isNull(billingAccount)) { + if (billingAccount != null) { fieldMapBuilder.put("billing_account", billingAccount); } fieldValuesMap = fieldMapBuilder.build(); @@ -336,7 +336,7 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return !Objects.isNull(fixedValue) ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } @Override diff --git a/test/integration/goldens/logging/LogExclusionName.java b/test/integration/goldens/logging/LogExclusionName.java index 037561fda3..e74aa57593 100644 --- a/test/integration/goldens/logging/LogExclusionName.java +++ b/test/integration/goldens/logging/LogExclusionName.java @@ -238,7 +238,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (LogExclusionName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -256,23 +256,23 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(project)) { + if (project != null) { fieldMapBuilder.put("project", project); } - if (!Objects.isNull(exclusion)) { + if (exclusion != null) { fieldMapBuilder.put("exclusion", exclusion); } - if (!Objects.isNull(organization)) { + if (organization != null) { fieldMapBuilder.put("organization", organization); } - if (!Objects.isNull(folder)) { + if (folder != null) { fieldMapBuilder.put("folder", folder); } - if (!Objects.isNull(billingAccount)) { + if (billingAccount != null) { fieldMapBuilder.put("billing_account", billingAccount); } fieldValuesMap = fieldMapBuilder.build(); @@ -288,7 +288,7 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return !Objects.isNull(fixedValue) ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } @Override diff --git a/test/integration/goldens/logging/LogMetricName.java b/test/integration/goldens/logging/LogMetricName.java index 2b50476244..8776fea12d 100644 --- a/test/integration/goldens/logging/LogMetricName.java +++ b/test/integration/goldens/logging/LogMetricName.java @@ -91,7 +91,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (LogMetricName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -106,14 +106,14 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(project)) { + if (project != null) { fieldMapBuilder.put("project", project); } - if (!Objects.isNull(metric)) { + if (metric != null) { fieldMapBuilder.put("metric", metric); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/test/integration/goldens/logging/LogName.java b/test/integration/goldens/logging/LogName.java index 7a1e540e8f..3ee9051322 100644 --- a/test/integration/goldens/logging/LogName.java +++ b/test/integration/goldens/logging/LogName.java @@ -224,7 +224,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (LogName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -242,23 +242,23 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(project)) { + if (project != null) { fieldMapBuilder.put("project", project); } - if (!Objects.isNull(log)) { + if (log != null) { fieldMapBuilder.put("log", log); } - if (!Objects.isNull(organization)) { + if (organization != null) { fieldMapBuilder.put("organization", organization); } - if (!Objects.isNull(folder)) { + if (folder != null) { fieldMapBuilder.put("folder", folder); } - if (!Objects.isNull(billingAccount)) { + if (billingAccount != null) { fieldMapBuilder.put("billing_account", billingAccount); } fieldValuesMap = fieldMapBuilder.build(); @@ -274,7 +274,7 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return !Objects.isNull(fixedValue) ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } @Override diff --git a/test/integration/goldens/logging/LogSinkName.java b/test/integration/goldens/logging/LogSinkName.java index c078226190..a5a7ba2d4c 100644 --- a/test/integration/goldens/logging/LogSinkName.java +++ b/test/integration/goldens/logging/LogSinkName.java @@ -228,7 +228,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (LogSinkName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -246,23 +246,23 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(project)) { + if (project != null) { fieldMapBuilder.put("project", project); } - if (!Objects.isNull(sink)) { + if (sink != null) { fieldMapBuilder.put("sink", sink); } - if (!Objects.isNull(organization)) { + if (organization != null) { fieldMapBuilder.put("organization", organization); } - if (!Objects.isNull(folder)) { + if (folder != null) { fieldMapBuilder.put("folder", folder); } - if (!Objects.isNull(billingAccount)) { + if (billingAccount != null) { fieldMapBuilder.put("billing_account", billingAccount); } fieldValuesMap = fieldMapBuilder.build(); @@ -278,7 +278,7 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return !Objects.isNull(fixedValue) ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } @Override diff --git a/test/integration/goldens/logging/LoggingClient.java b/test/integration/goldens/logging/LoggingClient.java index 8b80772613..2b7cef1ad5 100644 --- a/test/integration/goldens/logging/LoggingClient.java +++ b/test/integration/goldens/logging/LoggingClient.java @@ -50,7 +50,6 @@ import java.io.IOException; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -175,7 +174,7 @@ public LoggingServiceV2Stub getStub() { public final void deleteLog(LogName logName) { DeleteLogRequest request = DeleteLogRequest.newBuilder() - .setLogName(Objects.isNull(logName) ? null : logName.toString()) + .setLogName(logName == null ? null : logName.toString()) .build(); deleteLog(request); } @@ -278,7 +277,7 @@ public final WriteLogEntriesResponse writeLogEntries( List entries) { WriteLogEntriesRequest request = WriteLogEntriesRequest.newBuilder() - .setLogName(Objects.isNull(logName) ? null : logName.toString()) + .setLogName(logName == null ? null : logName.toString()) .setResource(resource) .putAllLabels(labels) .addAllEntries(entries) @@ -498,9 +497,7 @@ public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResource */ public final ListLogsPagedResponse listLogs(BillingAccountName parent) { ListLogsRequest request = - ListLogsRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) - .build(); + ListLogsRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); return listLogs(request); } @@ -516,9 +513,7 @@ public final ListLogsPagedResponse listLogs(BillingAccountName parent) { */ public final ListLogsPagedResponse listLogs(FolderName parent) { ListLogsRequest request = - ListLogsRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) - .build(); + ListLogsRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); return listLogs(request); } @@ -534,9 +529,7 @@ public final ListLogsPagedResponse listLogs(FolderName parent) { */ public final ListLogsPagedResponse listLogs(OrganizationName parent) { ListLogsRequest request = - ListLogsRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) - .build(); + ListLogsRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); return listLogs(request); } @@ -552,9 +545,7 @@ public final ListLogsPagedResponse listLogs(OrganizationName parent) { */ public final ListLogsPagedResponse listLogs(ProjectName parent) { ListLogsRequest request = - ListLogsRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) - .build(); + ListLogsRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); return listLogs(request); } diff --git a/test/integration/goldens/logging/LoggingServiceV2StubSettings.java b/test/integration/goldens/logging/LoggingServiceV2StubSettings.java index fa283cce96..47b910ab99 100644 --- a/test/integration/goldens/logging/LoggingServiceV2StubSettings.java +++ b/test/integration/goldens/logging/LoggingServiceV2StubSettings.java @@ -69,7 +69,6 @@ import java.io.IOException; import java.util.Collection; import java.util.List; -import java.util.Objects; import javax.annotation.Generated; import org.threeten.bp.Duration; @@ -163,7 +162,7 @@ public String extractNextToken(ListLogEntriesResponse payload) { @Override public Iterable extractResources(ListLogEntriesResponse payload) { - return Objects.isNull(payload.getEntriesList()) + return payload.getEntriesList() == null ? ImmutableList.of() : payload.getEntriesList(); } @@ -212,7 +211,7 @@ public String extractNextToken(ListMonitoredResourceDescriptorsResponse payload) @Override public Iterable extractResources( ListMonitoredResourceDescriptorsResponse payload) { - return Objects.isNull(payload.getResourceDescriptorsList()) + return payload.getResourceDescriptorsList() == null ? ImmutableList.of() : payload.getResourceDescriptorsList(); } @@ -248,7 +247,7 @@ public String extractNextToken(ListLogsResponse payload) { @Override public Iterable extractResources(ListLogsResponse payload) { - return Objects.isNull(payload.getLogNamesList()) + return payload.getLogNamesList() == null ? ImmutableList.of() : payload.getLogNamesList(); } @@ -336,7 +335,7 @@ public RequestBuilder getRequestBuilder() { @Override public void appendRequest(WriteLogEntriesRequest request) { - if (Objects.isNull(builder)) { + if (builder == null) { builder = request.toBuilder(); } else { builder.addAllEntries(request.getEntriesList()); diff --git a/test/integration/goldens/logging/MetricsClient.java b/test/integration/goldens/logging/MetricsClient.java index ab7d4fde63..a7a58f48b8 100644 --- a/test/integration/goldens/logging/MetricsClient.java +++ b/test/integration/goldens/logging/MetricsClient.java @@ -41,7 +41,6 @@ import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; -import java.util.Objects; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -160,7 +159,7 @@ public MetricsServiceV2Stub getStub() { public final ListLogMetricsPagedResponse listLogMetrics(ProjectName parent) { ListLogMetricsRequest request = ListLogMetricsRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .build(); return listLogMetrics(request); } @@ -222,7 +221,7 @@ public final ListLogMetricsPagedResponse listLogMetrics(ListLogMetricsRequest re public final LogMetric getLogMetric(LogMetricName metricName) { GetLogMetricRequest request = GetLogMetricRequest.newBuilder() - .setMetricName(Objects.isNull(metricName) ? null : metricName.toString()) + .setMetricName(metricName == null ? null : metricName.toString()) .build(); return getLogMetric(request); } @@ -276,7 +275,7 @@ public final UnaryCallable getLogMetricCallable( public final LogMetric createLogMetric(ProjectName parent, LogMetric metric) { CreateLogMetricRequest request = CreateLogMetricRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .setMetric(metric) .build(); return createLogMetric(request); @@ -335,7 +334,7 @@ public final UnaryCallable createLogMetricCal public final LogMetric updateLogMetric(LogMetricName metricName, LogMetric metric) { UpdateLogMetricRequest request = UpdateLogMetricRequest.newBuilder() - .setMetricName(Objects.isNull(metricName) ? null : metricName.toString()) + .setMetricName(metricName == null ? null : metricName.toString()) .setMetric(metric) .build(); return updateLogMetric(request); @@ -391,7 +390,7 @@ public final UnaryCallable updateLogMetricCal public final void deleteLogMetric(LogMetricName metricName) { DeleteLogMetricRequest request = DeleteLogMetricRequest.newBuilder() - .setMetricName(Objects.isNull(metricName) ? null : metricName.toString()) + .setMetricName(metricName == null ? null : metricName.toString()) .build(); deleteLogMetric(request); } diff --git a/test/integration/goldens/logging/MetricsServiceV2StubSettings.java b/test/integration/goldens/logging/MetricsServiceV2StubSettings.java index 25b623eaee..94082fb1c4 100644 --- a/test/integration/goldens/logging/MetricsServiceV2StubSettings.java +++ b/test/integration/goldens/logging/MetricsServiceV2StubSettings.java @@ -54,7 +54,6 @@ import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; -import java.util.Objects; import javax.annotation.Generated; import org.threeten.bp.Duration; @@ -142,7 +141,7 @@ public String extractNextToken(ListLogMetricsResponse payload) { @Override public Iterable extractResources(ListLogMetricsResponse payload) { - return Objects.isNull(payload.getMetricsList()) + return payload.getMetricsList() == null ? ImmutableList.of() : payload.getMetricsList(); } diff --git a/test/integration/goldens/logging/OrganizationLocationName.java b/test/integration/goldens/logging/OrganizationLocationName.java index f01aea1f66..8ccd632926 100644 --- a/test/integration/goldens/logging/OrganizationLocationName.java +++ b/test/integration/goldens/logging/OrganizationLocationName.java @@ -91,7 +91,7 @@ public static List parseList(List formattedStr public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (OrganizationLocationName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -106,14 +106,14 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(organization)) { + if (organization != null) { fieldMapBuilder.put("organization", organization); } - if (!Objects.isNull(location)) { + if (location != null) { fieldMapBuilder.put("location", location); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/test/integration/goldens/logging/OrganizationName.java b/test/integration/goldens/logging/OrganizationName.java index fdc5f8eaa3..d3183b6d27 100644 --- a/test/integration/goldens/logging/OrganizationName.java +++ b/test/integration/goldens/logging/OrganizationName.java @@ -84,7 +84,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (OrganizationName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -99,11 +99,11 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(organization)) { + if (organization != null) { fieldMapBuilder.put("organization", organization); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/test/integration/goldens/logging/ProjectName.java b/test/integration/goldens/logging/ProjectName.java index 58101d3f7a..adafd1af08 100644 --- a/test/integration/goldens/logging/ProjectName.java +++ b/test/integration/goldens/logging/ProjectName.java @@ -84,7 +84,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (ProjectName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -99,11 +99,11 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(project)) { + if (project != null) { fieldMapBuilder.put("project", project); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/test/integration/goldens/redis/CloudRedisClient.java b/test/integration/goldens/redis/CloudRedisClient.java index a65989a9f7..d58b981828 100644 --- a/test/integration/goldens/redis/CloudRedisClient.java +++ b/test/integration/goldens/redis/CloudRedisClient.java @@ -37,7 +37,6 @@ import com.google.protobuf.FieldMask; import java.io.IOException; import java.util.List; -import java.util.Objects; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -197,7 +196,7 @@ public final OperationsClient getOperationsClient() { public final ListInstancesPagedResponse listInstances(LocationName parent) { ListInstancesRequest request = ListInstancesRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .build(); return listInstances(request); } @@ -298,9 +297,7 @@ public final UnaryCallable listInst */ public final Instance getInstance(InstanceName name) { GetInstanceRequest request = - GetInstanceRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) - .build(); + GetInstanceRequest.newBuilder().setName(name == null ? null : name.toString()).build(); return getInstance(request); } @@ -373,7 +370,7 @@ public final OperationFuture createInstanceAsync( LocationName parent, String instanceId, Instance instance) { CreateInstanceRequest request = CreateInstanceRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .setInstanceId(instanceId) .setInstance(instance) .build(); @@ -568,7 +565,7 @@ public final OperationFuture upgradeInstanceAsync( InstanceName name, String redisVersion) { UpgradeInstanceRequest request = UpgradeInstanceRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) + .setName(name == null ? null : name.toString()) .setRedisVersion(redisVersion) .build(); return upgradeInstanceAsync(request); @@ -784,7 +781,7 @@ public final OperationFuture failoverInstanceAsync( InstanceName name, FailoverInstanceRequest.DataProtectionMode dataProtectionMode) { FailoverInstanceRequest request = FailoverInstanceRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) + .setName(name == null ? null : name.toString()) .setDataProtectionMode(dataProtectionMode) .build(); return failoverInstanceAsync(request); @@ -859,9 +856,7 @@ public final UnaryCallable failoverInstanceC */ public final OperationFuture deleteInstanceAsync(InstanceName name) { DeleteInstanceRequest request = - DeleteInstanceRequest.newBuilder() - .setName(Objects.isNull(name) ? null : name.toString()) - .build(); + DeleteInstanceRequest.newBuilder().setName(name == null ? null : name.toString()).build(); return deleteInstanceAsync(request); } diff --git a/test/integration/goldens/redis/CloudRedisStubSettings.java b/test/integration/goldens/redis/CloudRedisStubSettings.java index 6123d677eb..85739cc9a1 100644 --- a/test/integration/goldens/redis/CloudRedisStubSettings.java +++ b/test/integration/goldens/redis/CloudRedisStubSettings.java @@ -64,7 +64,6 @@ import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; -import java.util.Objects; import javax.annotation.Generated; import org.threeten.bp.Duration; @@ -162,7 +161,7 @@ public String extractNextToken(ListInstancesResponse payload) { @Override public Iterable extractResources(ListInstancesResponse payload) { - return Objects.isNull(payload.getInstancesList()) + return payload.getInstancesList() == null ? ImmutableList.of() : payload.getInstancesList(); } diff --git a/test/integration/goldens/redis/InstanceName.java b/test/integration/goldens/redis/InstanceName.java index 56f2d728b1..d3613b41c2 100644 --- a/test/integration/goldens/redis/InstanceName.java +++ b/test/integration/goldens/redis/InstanceName.java @@ -104,7 +104,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (InstanceName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -119,17 +119,17 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(project)) { + if (project != null) { fieldMapBuilder.put("project", project); } - if (!Objects.isNull(location)) { + if (location != null) { fieldMapBuilder.put("location", location); } - if (!Objects.isNull(instance)) { + if (instance != null) { fieldMapBuilder.put("instance", instance); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/test/integration/goldens/redis/LocationName.java b/test/integration/goldens/redis/LocationName.java index 4f2c953ed7..966cb332b5 100644 --- a/test/integration/goldens/redis/LocationName.java +++ b/test/integration/goldens/redis/LocationName.java @@ -91,7 +91,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (LocationName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -106,14 +106,14 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(project)) { + if (project != null) { fieldMapBuilder.put("project", project); } - if (!Objects.isNull(location)) { + if (location != null) { fieldMapBuilder.put("location", location); } fieldValuesMap = fieldMapBuilder.build();