Skip to content

Commit b4e20e0

Browse files
authored
Corrections to the documentation (tfaulkes). (#19)
1 parent bbc658c commit b4e20e0

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

README.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ p.setSsn("123456789");
175175
p.setAge(17);
176176
177177
AerospikeClient client = new AerospikeClient("aerospike hostname",3000);
178-
AeroMapper mapper = new AeroMapper(client);
178+
AeroMapper mapper = new AeroMapper.Builder(client).build();
179179
mapper.save(p);
180180
```
181181
@@ -252,7 +252,7 @@ In this case the `forAll()` would apply to A,B,C, the `forThisOrChildrenOf` woul
252252
253253
Note that each operation can also optionally take a policy if it is desired to change any of the policy settings on the fly. The explicitly provided policy will override any other settings, such as `durableDelete` on the `@AerospikeRecord`
254254
255-
if it is desired to change one part of a policy but keep the rest as the defaults set up with these policies, the appropriate policy can be read with `getReadPolicy`, `getWritePolicy`, `getBatchPolicy`, `getScanPolicy` and `getQueryPolicy` methods on the AeroMapper. For example, if we needed a policy which was preiously set up on a Customer class but needed to change the `durableDelete` property, we could do
255+
If it is desired to change one part of a policy but keep the rest as the defaults set up with these policies, the appropriate policy can be read with `getReadPolicy`, `getWritePolicy`, `getBatchPolicy`, `getScanPolicy` and `getQueryPolicy` methods on the AeroMapper. For example, if we need a policy which was previously set up on a Customer class but need to change the `durableDelete` property, we could do
256256
257257
```java
258258
WritePolicy writePolicy = mapper.getWritePolicy(Customer.class);
@@ -305,7 +305,10 @@ public class ConstructedClass {
305305
public final String name;
306306
public final Date date;
307307
308-
public ConstructedClass(@ParamFrom("id") int id, @ParamFrom("age") int age, @ParamFrom("name") String name, @ParamFrom("date")Date date) {
308+
public ConstructedClass(@ParamFrom("id") int id,
309+
@ParamFrom("age") int age,
310+
@ParamFrom("name") String name,
311+
@ParamFrom("date") Date date) {
309312
super();
310313
this.id = id;
311314
this.age = age;
@@ -348,7 +351,9 @@ public class ConstructedClass2 {
348351
}
349352
```
350353
351-
Whilst these examples show only final fields being set, this is not a requirement.
354+
When an instance of the ConstructedClass2 is read from the database, the constructor will be invoked and `a` and `id` set via the constructor, then `b` and `c` will be set by direct field access.
355+
356+
Note that whilst these examples show only final fields being set, this is not a requirement. The constructor can set any or all fields.
352357
353358
If there are multiple constructors on the class, the one to be used by the AeroMapper should be annotated with @AerospikeConstructor:
354359
@@ -374,9 +379,9 @@ public class ConstructedClass2 {
374379
}
375380
```
376381
377-
In this case, the 3 argument constructor will be used. Note that you must annotate the desired constructor with @AerospikeConstructor on any class with multiple constructors, irrespective of how many of those constructors have the @ParamFrom annotations on their arguments. It is only allowed to have one constructor so annotated.
382+
In this case, the 3 argument constructor will be used. Note that you must annotate the desired constructor with @AerospikeConstructor on any class with multiple constructors, irrespective of how many of those constructors have the @ParamFrom annotations on their arguments. If more than 1 constructor is annotated with @AerospikeConstructor on a class an exception will be thrown the first time the mapper sees that class.
378383
379-
If no constructor is annotated with @AerospikeConstructor, the default no-argument constructor will be used. If there is no no-argument constructor and no @AerospikeConstructor annotated constructor has been declared, an exception will be thrown when the class is first used.
384+
If no constructor is annotated with @AerospikeConstructor, the default no-argument constructor will be used. If there is no no-argument constructor but only one constructor on the class, that constructor will be used. If there is no default constructor and multiple other constructors but no @AerospikeConstructor annotated constructor has been declared, an exception will be thrown when the class is first used.
380385
381386
---
382387
@@ -596,11 +601,12 @@ Here are how standard Java types are mapped to Aerospike types:
596601
| Map<?,?> | Map |
597602
| Object Reference (@AerospikeRecord) | List or Map |
598603
599-
These types are built into the converter. However, if you wish to change them, you can use a (Custom Object Converter)]custom-object-converter]. For example, if you want Dates stored in the database as a string, you could do:
604+
These types are built into the converter. However, if you wish to change them, you can use a (Custom Object Converter)[custom-object-converter]. For example, if you want Dates stored in the database as a string, you could do:
600605
601606
```java
602607
public static class DateConverter {
603-
private static final ThreadLocal<SimpleDateFormat> dateFormatter = ThreadLocal.withInitial(() -> new SimpleDateFormat("dd-MM-yyyy HH:mm:ss.SSS zzzZ"));
608+
private static final ThreadLocal<SimpleDateFormat> dateFormatter = ThreadLocal.withInitial(() ->
609+
new SimpleDateFormat("dd-MM-yyyy HH:mm:ss.SSS zzzZ"));
604610
@ToAerospike
605611
public String toAerospike(Date date) {
606612
if (date == null) {
@@ -1187,7 +1193,9 @@ This gets saved in the database as:
11871193
```
11881194
id: 1
11891195
name: "Savings Account"
1190-
transactions: MAP('{"Txn1":[100, 1610478132904000000, "Bob's store", "Txn1"], "Txn2":[134.99, 1610449332904000000, "Kim's store", "Txn2"], "Txn3":[75.43000000000001, 1610406132907000000, "Sue's store", "Txn3"]}')
1196+
transactions: MAP('{"Txn1":[100, 1610478132904000000, "Bob's store", "Txn1"],
1197+
"Txn2":[134.99, 1610449332904000000, "Kim's store", "Txn2"],
1198+
"Txn3":[75.43000000000001, 1610406132907000000, "Sue's store", "Txn3"]}')
11911199
type: "SAVINGS"
11921200
```
11931201
@@ -1219,7 +1227,9 @@ Now the data will be saved in a different format with the transaction time the f
12191227
```
12201228
id: 1
12211229
name: "Savings Account"
1222-
transactions: MAP('{"Txn1":[1610478716965000000, 100, "Bob's store", "Txn1"], "Txn2":[1610449916965000000, 134.99, "Kim's store", "Txn2"], "Txn3":[1610406716967000000, 75.43000000000001, "Sue's store", "Txn3"]}')
1230+
transactions: MAP('{"Txn1":[1610478716965000000, 100, "Bob's store", "Txn1"],
1231+
"Txn2":[1610449916965000000, 134.99, "Kim's store", "Txn2"],
1232+
"Txn3":[1610406716967000000, 75.43000000000001, "Sue's store", "Txn3"]}')
12231233
type: "SAVINGS"
12241234
```
12251235

0 commit comments

Comments
 (0)