Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit af79f8f

Browse files
committed
Refactor Datastore example, add example on embedded entities (googleapis#980)
* Refactor Datastore example, add example on embedded entities * Minor refactoring of examples - Favor printf over println - Rename Action argument from request to arg
1 parent 8fc4f7a commit af79f8f

File tree

7 files changed

+372
-258
lines changed

7 files changed

+372
-258
lines changed

gcloud-java-examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ To run examples from your command line:
8181
mvn exec:java -Dexec.mainClass="com.google.cloud.examples.datastore.DatastoreExample" -Dexec.args="your-project-id my_name add my\ comment"
8282
mvn exec:java -Dexec.mainClass="com.google.cloud.examples.datastore.DatastoreExample" -Dexec.args="your-project-id my_name display"
8383
mvn exec:java -Dexec.mainClass="com.google.cloud.examples.datastore.DatastoreExample" -Dexec.args="your-project-id my_name delete"
84+
mvn exec:java -Dexec.mainClass="com.google.cloud.examples.datastore.DatastoreExample" -Dexec.args="your-project-id my_name set [email protected] 1234"
8485
```
8586
8687
* Here's an example run of `DnsExample`.

gcloud-java-examples/src/main/java/com/google/cloud/examples/bigquery/BigQueryExample.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public class BigQueryExample {
108108

109109
private abstract static class BigQueryAction<T> {
110110

111-
abstract void run(BigQuery bigquery, T request) throws Exception;
111+
abstract void run(BigQuery bigquery, T arg) throws Exception;
112112

113113
abstract T parse(String... args) throws Exception;
114114

@@ -775,18 +775,18 @@ public static void main(String... args) throws Exception {
775775
return;
776776
}
777777
BigQuery bigquery = optionsBuilder.build().service();
778-
Object request;
778+
Object arg;
779779
try {
780-
request = action.parse(args);
780+
arg = action.parse(args);
781781
} catch (IllegalArgumentException ex) {
782-
System.out.println("Invalid input for action '" + actionName + "'. " + ex.getMessage());
783-
System.out.println("Expected: " + action.params());
782+
System.out.printf("Invalid input for action '%s'. %s%n", actionName, ex.getMessage());
783+
System.out.printf("Expected: %s%n", action.params());
784784
return;
785785
} catch (Exception ex) {
786-
System.out.println("Failed to parse request.");
786+
System.out.println("Failed to parse arguments.");
787787
ex.printStackTrace();
788788
return;
789789
}
790-
action.run(bigquery, request);
790+
action.run(bigquery, arg);
791791
}
792792
}

0 commit comments

Comments
 (0)