Skip to content

Commit 6842c5c

Browse files
committed
refactor(bigtable-snippets): shorten FieldMask, FileNotFoundException, and Map.Entry FQCNs
1 parent 413cbf8 commit 6842c5c

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

java-bigtable/samples/snippets/src/main/java/com/example/bigtable/AuthorizedViewExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.google.cloud.bigtable.data.v2.models.RowCell;
4141
import com.google.cloud.bigtable.data.v2.models.RowMutation;
4242
import com.google.protobuf.ByteString;
43+
import com.google.protobuf.FieldMask;
4344
import java.io.IOException;
4445
import java.util.ArrayList;
4546
import java.util.List;
@@ -230,8 +231,7 @@ public void updateAuthorizedView() {
230231
UpdateAuthorizedViewRequest request =
231232
UpdateAuthorizedViewRequest.newBuilder()
232233
.setAuthorizedView(authorizedViewObj)
233-
.setUpdateMask(
234-
com.google.protobuf.FieldMask.newBuilder().addPaths("subset_view").build())
234+
.setUpdateMask(FieldMask.newBuilder().addPaths("subset_view").build())
235235
.build();
236236
AuthorizedView authorizedView = adminClient.updateAuthorizedViewAsync(request).get();
237237
System.out.printf("AuthorizedView: %s updated successfully%n", authorizedView.getName());

java-bigtable/samples/snippets/src/main/java/com/example/bigtable/SchemaBundleExample.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
import com.google.cloud.bigtable.admin.v2.BigtableTableAdminClientV2;
3131
import com.google.protobuf.ByteString;
3232
import com.google.protobuf.DescriptorProtos;
33+
import com.google.protobuf.FieldMask;
3334
import com.google.protobuf.InvalidProtocolBufferException;
35+
import java.io.FileNotFoundException;
3436
import java.io.IOException;
3537
import java.io.InputStream;
3638
import java.util.ArrayList;
@@ -163,7 +165,7 @@ public void createSchemaBundle() {
163165
// [START bigtable_create_schema_bundle]
164166
try (InputStream in = getClass().getClassLoader().getResourceAsStream(PROTO_FILE_PATH)) {
165167
if (in == null) {
166-
throw new java.io.FileNotFoundException("Resource not found: " + PROTO_FILE_PATH);
168+
throw new FileNotFoundException("Resource not found: " + PROTO_FILE_PATH);
167169
}
168170
SchemaBundle schemaBundleObj =
169171
SchemaBundle.newBuilder()
@@ -192,7 +194,7 @@ public void updateSchemaBundle() {
192194
// [START bigtable_update_schema_bundle]
193195
try (InputStream in = getClass().getClassLoader().getResourceAsStream(PROTO_FILE_PATH)) {
194196
if (in == null) {
195-
throw new java.io.FileNotFoundException("Resource not found: " + PROTO_FILE_PATH);
197+
throw new FileNotFoundException("Resource not found: " + PROTO_FILE_PATH);
196198
}
197199
SchemaBundle schemaBundleObj =
198200
SchemaBundle.newBuilder()
@@ -211,8 +213,7 @@ public void updateSchemaBundle() {
211213
UpdateSchemaBundleRequest request =
212214
UpdateSchemaBundleRequest.newBuilder()
213215
.setSchemaBundle(schemaBundleObj)
214-
.setUpdateMask(
215-
com.google.protobuf.FieldMask.newBuilder().addPaths("proto_schema").build())
216+
.setUpdateMask(FieldMask.newBuilder().addPaths("proto_schema").build())
216217
.build();
217218
SchemaBundle schemaBundle = adminClient.updateSchemaBundleAsync(request).get();
218219
System.out.printf("Schema bundle: %s updated successfully%n", schemaBundle.getName());

java-bigtable/samples/snippets/src/main/java/com/example/bigtable/TableAdminExample.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.google.cloud.bigtable.admin.v2.models.GcRuleBuilder;
3030
import java.io.IOException;
3131
import java.time.Duration;
32+
import java.util.Map;
3233

3334
/**
3435
* An example of using Google Cloud Bigtable.
@@ -168,8 +169,7 @@ public void getTableMeta() {
168169
"projects/" + projectId + "/instances/" + instanceId + "/tables/" + tableId;
169170
Table table = adminClient.getTable(tableName);
170171
System.out.println("Table: " + table.getName());
171-
for (java.util.Map.Entry<String, ColumnFamily> entry :
172-
table.getColumnFamiliesMap().entrySet()) {
172+
for (Map.Entry<String, ColumnFamily> entry : table.getColumnFamiliesMap().entrySet()) {
173173
System.out.printf(
174174
"Column family: %s%nGC Rule: %s%n", entry.getKey(), entry.getValue().getGcRule());
175175
}
@@ -357,8 +357,7 @@ public void listColumnFamilies() {
357357
String tableName =
358358
"projects/" + projectId + "/instances/" + instanceId + "/tables/" + tableId;
359359
Table table = adminClient.getTable(tableName);
360-
for (java.util.Map.Entry<String, ColumnFamily> entry :
361-
table.getColumnFamiliesMap().entrySet()) {
360+
for (Map.Entry<String, ColumnFamily> entry : table.getColumnFamiliesMap().entrySet()) {
362361
System.out.printf(
363362
"Column family: %s%nGC Rule: %s%n", entry.getKey(), entry.getValue().getGcRule());
364363
}

0 commit comments

Comments
 (0)