From 083acf4a9735bccd833a24bc51cd68d411ef2ac9 Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Tue, 17 Feb 2015 13:32:28 -0500 Subject: [PATCH] Syntax highlight Java code snippet. --- README.md | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 3f8dcf9182bf..2ffe0742ccc7 100644 --- a/README.md +++ b/README.md @@ -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