Skip to content

Commit eeeccd1

Browse files
committed
readme fixes
1 parent 730926f commit eeeccd1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ The library is a part of the [Amplicode](https://amplicode.io/) project, however
1010
The implementation heavily depends on Jackson (version used by the Spring Web).
1111

1212
## Adding library to the project
13+
14+
The library has been published to the Maven Central repository.
15+
1316
Maven:
1417
```
1518
<dependency>
@@ -40,6 +43,7 @@ The bean performs patching the passed object under the following set of conditio
4043
Usage:
4144
```java
4245
import com.fasterxml.jackson.databind.JsonNode;
46+
import io.amplicode.rautils.patch.ObjectPatcher;
4347

4448
@Autowired
4549
private ObjectPatcher objectPatcher;
@@ -53,19 +57,20 @@ import com.fasterxml.jackson.databind.JsonNode;
5357
}
5458
```
5559

56-
**Note** that if DTO used in the endpoint is **mutable** (e.g. has setters for all attributes), then an existing method from the Jackson library can be used instead of the `ObjectPatcher`:
60+
**Note** that if DTO used in the endpoint is **mutable** (e.g. has setters for all attributes), then an existing method from the Jackson library can be used instead of the `ObjectPatcher` to patch the source object in-place:
5761
```java
5862
import com.fasterxml.jackson.databind.JsonNode;
63+
import com.fasterxml.jackson.databind.ObjectMapper;
5964

6065
@Autowired
6166
private ObjectMapper objectMapper;
6267

6368
@PatchMapping("/{id}")
6469
public ResponseEntity<FooDto> patch(@PathVariable Integer id, @RequestBody JsonNode fooDtoPatch) throws IOException {
6570
FooDto fooDto; // load current state of the entity
66-
FooDto patchedDto = objectMapper.readerForUpdating(fooDto).readValue(fooDtoPatch);
71+
objectMapper.readerForUpdating(fooDto).readValue(fooDtoPatch);
6772

68-
// save patchedDto to the data store
73+
// save fooDto to the data store
6974
}
7075
```
7176

@@ -75,8 +80,10 @@ import com.fasterxml.jackson.databind.JsonNode;
7580
Therefore, it is required to validate patched object in the endpoint code. Unfortunately, Spring doesn't provide one-liner API to perform such validation. As a shortcut to perform the validation, `ObjectPatcher` provides several methods:
7681

7782
```java
83+
import io.amplicode.rautils.patch.ObjectPatcher;
84+
7885
@Autowired
79-
private ObjectMapper objectMapper;
86+
private ObjectPatcher objectPatcher;
8087

8188
// just validate
8289
// public void ObjectPatcher#validate(Object target);

0 commit comments

Comments
 (0)