Skip to content

Commit a0d1164

Browse files
authored
Update README.md (#130)
1 parent 041c612 commit a0d1164

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

README.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@ The documentation for this project can be found on [javadoc.io](https://www.java
5050
| 1.2.x, 1.3.x, 1.4.x | 5.1.x | 5.0.x
5151
| 1.1.x | 5.0.x |
5252

53+
# Installing the Mapper
54+
The easiest way to use the mapper is through Maven or Gradle. For Maven, pull it in from Maven Central:
55+
```
56+
<!-- https://mvnrepository.com/artifact/com.aerospike/java-object-mapper -->
57+
<dependency>
58+
<groupId>com.aerospike</groupId>
59+
<artifactId>java-object-mapper</artifactId>
60+
<version>2.1.0</version>
61+
</dependency>
62+
```
63+
For Gradle, you can use
64+
```
65+
// https://mvnrepository.com/artifact/com.aerospike/java-object-mapper
66+
implementation group: 'com.aerospike', name: 'java-object-mapper', version: '2.1.0'
67+
```
68+
5369
# Motivation and a simple example
5470
Consider a simple class:
5571

@@ -264,10 +280,11 @@ Note that each operation can also optionally take a policy if it is desired to c
264280
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
265281
266282
```java
267-
WritePolicy writePolicy = mapper.getWritePolicy(Customer.class);
283+
WritePolicy writePolicy = new WritePolicy(mapper.getWritePolicy(Customer.class));
268284
writePolicy.durableDelete = true;
269285
mapper.delete(writePolicy, myCustomer);
270286
```
287+
Note that the `getXxxPolicy` methods return the actual underlying policy rather than a copy of it, so it is best to instantiate a new instance of this object before changing it.
271288
272289
In summary, the policy which will be used for a call are: (lower number is a higher priority)
273290
@@ -1917,6 +1934,7 @@ classes:
19171934
elementType: LIST
19181935
name: data
19191936
```
1937+
(Note: DataClass and ContainerClasss were defined as static inner classes inside AeroMapperConfigurationYamlTest, hence the need for the long class name. In real production applications this isn't likely to be needed)
19201938

19211939
### File Structure
19221940
The structure of the file is:
@@ -2088,7 +2106,7 @@ name: "container"
20882106
```
20892107
20902108
Note however that the list in the object in memory still contains only 4 items. *Virtual lists affect only the database representation of the data and not the Java POJO.*
2091-
Virtual Lists tend to use the (Operate)[https://www.aerospike.com/docs/client/java/usage/kvs/multiops.html] command which allows multiple operations to be performed on the same key at the same time. As a consequence, multiple commands can be done on a list with a single Aerospike operation. For example:
2109+
Virtual Lists tend to use the [Operate](https://www.aerospike.com/docs/client/java/usage/kvs/multiops.html) command which allows multiple operations to be performed on the same key at the same time. As a consequence, multiple commands can be done on a list with a single Aerospike operation. For example:
20922110
20932111
```java
20942112
List<Item> results = (List<Item>) list.beginMultiOperation()
@@ -2124,7 +2142,7 @@ List<Item> results = (List<Item>) list.beginMultiOperation()
21242142
21252143
Then the result would be the result of the `removeByKey`, which by default is null. (Write operations pass a ReturnType of NONE to CDT operations by default)
21262144
2127-
However, if we wanted a particular operation in the list to return it's result, we can flag it with `asResult()`. For example:
2145+
However, if we wanted a particular operation in the list to return its result, we can flag it with `asResult()`. For example:
21282146
21292147
```java
21302148
List<Item> results = (List<Item>) list.beginMultiOperation()
@@ -2134,7 +2152,7 @@ List<Item> results = (List<Item>) list.beginMultiOperation()
21342152
.end();
21352153
```
21362154
2137-
In this case, the element removed with with the `removeByKey(200)` will be returned, giving the data associated with item 200..
2155+
In this case, the element removed with with the `removeByKey(200)` will be returned, giving the data associated with item 200.
21382156
21392157
The type of the result (where supported) can also be changed with a call to `asResultOfType()`. For example:
21402158

0 commit comments

Comments
 (0)