Skip to content

Commit ea493d5

Browse files
author
Ajay Kannan
committed
simplify code snippets
1 parent e868ca3 commit ea493d5

3 files changed

Lines changed: 8 additions & 12 deletions

File tree

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ import com.google.gcloud.datastore.Entity;
6868
import com.google.gcloud.datastore.Key;
6969
import com.google.gcloud.datastore.KeyFactory;
7070

71-
DatastoreOptions options = DatastoreOptions.builder().build();
72-
Datastore datastore = DatastoreFactory.instance().get(options);
71+
Datastore datastore = DatastoreFactory.instance().get(DatastoreOptions.getDefaultInstance());
7372
KeyFactory keyFactory = datastore.newKeyFactory().kind(KIND);
7473
Key key = keyFactory.newKey(keyName);
7574
Entity entity = datastore.get(key);
@@ -112,8 +111,7 @@ import com.google.gcloud.storage.StorageOptions;
112111
import java.nio.ByteBuffer;
113112
import java.nio.channels.WritableByteChannel;
114113

115-
StorageOptions options = StorageOptions.builder().build();
116-
Storage storage = StorageFactory.instance().get(options);
114+
Storage storage = StorageFactory.instance().get(StorageOptions.getDefaultInstance());
117115
Blob blob = new Blob(storage, "bucket", "blob_name");
118116
if (!blob.exists()) {
119117
storage2.create(blob.info(), "Hello, Cloud Storage!".getBytes(UTF_8));

gcloud-java-datastore/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Example Application
3131
Authentication
3232
--------------
3333

34-
See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section in the main repository's README.
34+
See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section in the base directory's README.
3535

3636
About Google Cloud Datastore
3737
----------------------------
@@ -48,7 +48,7 @@ Cloud Datastore for your project.
4848
See the ``gcloud-java`` API [datastore documentation][datastore-api] to learn how to interact
4949
with the Cloud Datastore using this Client Library.
5050

51-
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) if running this snippet elsewhere.
51+
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) and a project ID if running this snippet elsewhere.
5252

5353
```java
5454
import com.google.gcloud.datastore.Datastore;
@@ -59,8 +59,7 @@ import com.google.gcloud.datastore.Entity;
5959
import com.google.gcloud.datastore.Key;
6060
import com.google.gcloud.datastore.KeyFactory;
6161

62-
DatastoreOptions options = DatastoreOptions.builder().projectId(PROJECT_ID).build();
63-
Datastore datastore = DatastoreFactory.instance().get(options);
62+
Datastore datastore = DatastoreFactory.instance().get(DatastoreOptions.getDefaultInstance());
6463
KeyFactory keyFactory = datastore.newKeyFactory().kind(KIND);
6564
Key key = keyFactory.newKey(keyName);
6665
Entity entity = datastore.get(key);

gcloud-java-storage/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Example Application
3232
Authentication
3333
--------------
3434

35-
See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section in the main repository's README.
35+
See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section in the base directory's README.
3636

3737
About Google Cloud Storage
3838
--------------------------
@@ -48,7 +48,7 @@ Cloud Storage for your project.
4848
See the ``gcloud-java`` API [storage documentation][storage-api] to learn how to interact
4949
with the Cloud Storage using this Client Library.
5050

51-
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) if running this snippet elsewhere.
51+
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) and a project ID if running this snippet elsewhere.
5252

5353
```java
5454
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -61,8 +61,7 @@ import com.google.gcloud.storage.StorageOptions;
6161
import java.nio.ByteBuffer;
6262
import java.nio.channels.WritableByteChannel;
6363

64-
StorageOptions options = StorageOptions.builder().projectId(PROJECT_ID).build();
65-
Storage storage = StorageFactory.instance().get(options);
64+
Storage storage = StorageFactory.instance().get(StorageOptions.getDefaultInstance());
6665
Blob blob = new Blob(storage, "bucket", "blob_name");
6766
if (!blob.exists()) {
6867
storage2.create(blob.info(), "Hello, Cloud Storage!".getBytes(UTF_8));

0 commit comments

Comments
 (0)