Skip to content

Commit ccb5547

Browse files
java code sample, !Scala
1 parent 61f2f24 commit ccb5547

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

modules/hello-world/pages/start-using-sdk.adoc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ Here we will use the `airport` collection within the `inventory` scope from `tra
303303

304304
[source,java]
305305
----
306-
include::devguide:example$scala/Cloud.scala[tag=collection,indent=0]
306+
include::devguide:example$java/StartUsingCapella.java[tag=collection,indent=0]
307307
----
308308

309309

@@ -318,9 +318,9 @@ We'll create a snippet of JSON to work with, using the client's own JSON library
318318
but you can read about the Scala SDK's support for other JSON libraries on the
319319
xref:howtos:json.adoc[] page.
320320

321-
[source,scala]
321+
[source,java]
322322
----
323-
include::devguide:example$scala/Cloud.scala[tag=json,indent=0]
323+
include::devguide:example$java/StartUsingCapella.java[tag=json,indent=0]
324324
----
325325

326326
=== Insert (Create) and Upsert
@@ -333,9 +333,9 @@ while the `upsert` operation will succeed, replacing the content.
333333
We need to provide a unique ID as the key, and we'll use a UUID here:
334334

335335
.Creating a new document
336-
[source,scala]
336+
[source,java]
337337
----
338-
include::devguide:example$scala/Cloud.scala[tag=upsert,indent=0]
338+
include::devguide:example$java/StartUsingCapella.java[tag=upsert,indent=0]
339339
----
340340

341341
=== Get (Read)
@@ -350,9 +350,9 @@ The easiest way to handle a single operation is with pattern matching, as shown
350350

351351
Now let's get the data back (this example will look a little messy due the nested handling of multiple `Try` results, but we'll see how to clean it up shortly):
352352

353-
[source,scala]
353+
[source,java]
354354
----
355-
include::devguide:example$scala/Cloud.scala[tag=get,indent=0]
355+
include::devguide:example$java/StartUsingCapella.java[tag=get,indent=0]
356356
----
357357

358358
Here we're fetching the value for the key `docId`,
@@ -366,16 +366,16 @@ and then accessing the value of the *status* key as a String.
366366
All three of these operations could fail, so there's quite a lot of error handling code here to do something quite simple.
367367
One way to improve on this is by using `flatMap`, like this:
368368

369-
[source,scala]
369+
[source,java]
370370
----
371-
include::devguide:example$scala/Cloud.scala[tag=get-map,indent=0]
371+
include::devguide:example$java/StartUsingCapella.java[tag=get-map,indent=0]
372372
----
373373

374374
Alternatively, you can use a for-comprehension, like so:
375375

376-
[source,scala]
376+
[source,java]
377377
----
378-
include::devguide:example$scala/Cloud.scala[tag=get-for,indent=0]
378+
include::devguide:example$java/StartUsingCapella.java[tag=get-for,indent=0]
379379
----
380380

381381
Either of these methods will stop on the first failed operation. So the final returned `Try` contains either
@@ -389,9 +389,9 @@ One will take an Options builder, which provides all possible options that opera
389389
For instance:
390390

391391
.The replace method updates the value of an existing document
392-
[source,scala]
392+
[source,java]
393393
----
394-
include::devguide:example$scala/Cloud.scala[tag=replace-options,indent=0]
394+
include::devguide:example$java/StartUsingCapella.java[tag=replace-options,indent=0]
395395
----
396396

397397
These options blocks are implemented as Scala case classes:
@@ -400,9 +400,9 @@ they are immutable data objects that return a copy of themselves on each change.
400400
The other overload is provided purely for convenience.
401401
It takes named arguments instead of an Options object, and provides only the most commonly used options:
402402

403-
[source,scala]
403+
[source,java]
404404
----
405-
include::devguide:example$scala/Cloud.scala[tag=replace-named,indent=0]
405+
include::devguide:example$java/StartUsingCapella.java[tag=replace-named,indent=0]
406406
----
407407

408408
CAUTION: When you replace a document, it's usually good practice to use xref:howtos:kv-operations.adoc#optimistic-locking[optimistic locking].
@@ -412,9 +412,9 @@ Otherwise, changes might get lost if two people change the same document at the
412412

413413
The remove method deletes a document from a collection:
414414

415-
[source,scala]
415+
[source,java]
416416
----
417-
include::devguide:example$scala/KvOperations.scala[indent=0,tag=remove]
417+
include::devguide:example$java/StartUsingCapella.java[indent=0,tag=remove]
418418
----
419419

420420

0 commit comments

Comments
 (0)