Skip to content

Commit

Permalink
Merge pull request #10 from mbrukman/readme-syntax-highlight
Browse files Browse the repository at this point in the history
Syntax highlight Java code snippet.
  • Loading branch information
aozarov committed Feb 18, 2015
2 parents 69ba166 + 083acf4 commit b3dd822
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,28 @@ consistency for all other queries.
Follow the [activation instructions][cloud-datastore-activation] to use the Google
Cloud Datastore API with your project.

import com.google.gcloud.datastore.DatastoreService;
import com.google.gcloud.datastore.DatastoreServiceFactory;
import com.google.gcloud.datastore.DatastoreServiceOptions;
import com.google.gcloud.datastore.Entity;
import com.google.gcloud.datastore.Key;
import com.google.gcloud.datastore.KeyFactory;

DatastoreServiceOptions options = DatastoreServiceOptions.builder().dataset("...").build();
DatastoreService datastore = DatastoreServiceFactory.getDefault(options);
KeyFactory keyFactory = new KeyFactory(datastore).kind("...");
Key key = keyFactory.newKey(keyName);
Entity entity = datastore.get(key);
if (entity == null) {
entity = Entity.builder(key)
.set("name", "John Do")
.set("age", 30)
.set("updated", false)
.build();
datastore.put(entity);
}
```java
import com.google.gcloud.datastore.DatastoreService;
import com.google.gcloud.datastore.DatastoreServiceFactory;
import com.google.gcloud.datastore.DatastoreServiceOptions;
import com.google.gcloud.datastore.Entity;
import com.google.gcloud.datastore.Key;
import com.google.gcloud.datastore.KeyFactory;

DatastoreServiceOptions options = DatastoreServiceOptions.builder().dataset("...").build();
DatastoreService datastore = DatastoreServiceFactory.getDefault(options);
KeyFactory keyFactory = new KeyFactory(datastore).kind("...");
Key key = keyFactory.newKey(keyName);
Entity entity = datastore.get(key);
if (entity == null) {
entity = Entity.builder(key)
.set("name", "John Do")
.set("age", 30)
.set("updated", false)
.build();
datastore.put(entity);
}
```

## Contributing

Expand Down

0 comments on commit b3dd822

Please sign in to comment.