Skip to content

Commit e723fb0

Browse files
committed
update the README.md
1 parent 61806d7 commit e723fb0

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

.run/All in diff-objects.run.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="All in diff-objects" type="JUnit" factoryName="JUnit" nameIsGenerated="true">
3+
<module name="diff-objects" />
4+
<option name="PACKAGE_NAME" value="" />
5+
<option name="MAIN_CLASS_NAME" value="" />
6+
<option name="METHOD_NAME" value="" />
7+
<option name="TEST_OBJECT" value="package" />
8+
<method v="2">
9+
<option name="Make" enabled="true" />
10+
</method>
11+
</configuration>
12+
</component>

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,11 @@ import com.github.jonpereiradev.diffobjects.builder.DiffConfigBuilder;
5454
public class Main {
5555

5656
public static void main(String[] args) {
57+
// creates 2 users for this example
5758
User u1 = new User("user1", "123456", LocalDate.now().minusDays(1), true);
5859
User u2 = new User("user2", "654321", LocalDate.now(), false);
5960

60-
u1.getEmails().add(new Email("user@gmail.com", true));
61-
u2.getEmails().add(new Email("user@gmail.com", false));
62-
61+
// creates the configuration for the diff
6362
DiffConfig diffConfig = DiffConfigBuilder
6463
.forClass(User.class)
6564
.mapping()
@@ -68,8 +67,10 @@ public class Main {
6867
.map("password")
6968
.build();
7069

70+
// executes the diff
7171
DiffResults diffResults = DiffObjects.forClass(User.class).diff(u1, u2, diffConfig);
7272

73+
// iterates over the results to show the differences
7374
for (DiffResult diffResult : diffResults) {
7475
if (!diffResult.isEquals()) {
7576
System.out.println("Field: " + diffResult.getField());
@@ -132,14 +133,18 @@ import com.github.jonpereiradev.diffobjects.DiffResult;
132133
public class Main {
133134

134135
public static void main(String[] args) {
136+
// creates 2 users for this example
135137
User u1 = new User("user1", "123456", LocalDate.now().minusDays(1), true);
136138
User u2 = new User("user2", "654321", LocalDate.now(), true);
137-
139+
140+
// creates 2 emails for this example
138141
u1.getEmails().add(new Email("user@gmail.com", true));
139142
u2.getEmails().add(new Email("user@gmail.com", false));
140143

144+
// executes the diff
141145
DiffResults diffResults = DiffObjects.forClass(User.class).diff(u1, u2);
142-
146+
147+
// iterates over the results to show the differences
143148
for (DiffResult diffResult : diffResults) {
144149
if (!diffResult.isEquals()) {
145150
System.out.println("Field: " + diffResult.getField());
@@ -153,10 +158,10 @@ public class Main {
153158

154159
### @DiffProperty
155160

156-
This annotation is used to provide more information in the DiffResult about the field. All objects already have the
157-
property "field" with the field name as value.
161+
This annotation is used to provide more information in the DiffResult about the field.
158162

159-
`@DiffProperty(key = "field", value = "{{fieldName}}")`
163+
All objects already have the property "field" with the field name as value.
164+
E.g. `@DiffProperty(key = "field", value = "{{fieldName}}")`
160165

161166
**Usage example**
162167

@@ -188,8 +193,10 @@ public class Main {
188193
public static void main(String[] args) {
189194
// code omitted ...
190195

196+
// executes the diff
191197
DiffResults diffResults = DiffObjects.forClass(User.class).diff(u1, u2);
192198

199+
// iterates over the results to show the differences
193200
for (DiffResult diffResult : diffResults) {
194201
if (diffResult.containsProperty("id")) {
195202
String id = diffResult.getProperty("id");

0 commit comments

Comments
 (0)