Skip to content

Commit

Permalink
Minor refactoring of examples
Browse files Browse the repository at this point in the history
- Favor printf over println
- Rename Action argument from request to arg
  • Loading branch information
mziccard committed May 12, 2016
1 parent 424e0b9 commit aa087fa
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public class BigQueryExample {

private abstract static class BigQueryAction<T> {

abstract void run(BigQuery bigquery, T request) throws Exception;
abstract void run(BigQuery bigquery, T arg) throws Exception;

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

Expand Down Expand Up @@ -775,18 +775,18 @@ public static void main(String... args) throws Exception {
return;
}
BigQuery bigquery = optionsBuilder.build().service();
Object request;
Object arg;
try {
request = action.parse(args);
arg = action.parse(args);
} catch (IllegalArgumentException ex) {
System.out.println("Invalid input for action '" + actionName + "'. " + ex.getMessage());
System.out.println("Expected: " + action.params());
System.out.printf("Invalid input for action '%s'. %s%n", actionName, ex.getMessage());
System.out.printf("Expected: %s%n", action.params());
return;
} catch (Exception ex) {
System.out.println("Failed to parse request.");
System.out.println("Failed to parse arguments.");
ex.printStackTrace();
return;
}
action.run(bigquery, request);
action.run(bigquery, arg);
}
}
Loading

0 comments on commit aa087fa

Please sign in to comment.