@@ -78,7 +78,7 @@ public enum PrimitiveDefaultValueMode
78
78
private final Collection <PropertyPath > excludedProperties = new HashSet <PropertyPath >(10 );
79
79
private final Collection <PropertyPath > equalsOnlyProperties = new LinkedHashSet <PropertyPath >(10 );
80
80
private final Collection <PropertyPathAndMethod > equalsOnlyValueProviderMethods = new LinkedHashSet <PropertyPathAndMethod >(10 );
81
- private final Collection <Class <?>> compareToOnlyTypes = new LinkedHashSet <Class <?>>(10 );
81
+ private final Collection <Class <?>> compareToOnlyTypes = new LinkedHashSet <Class <?>>(10 );
82
82
private final Collection <Class <?>> equalsOnlyTypes = new LinkedHashSet <Class <?>>(10 );
83
83
private final Collection <ClassAndMethod > equalsOnlyValueProviderTypes = new LinkedHashSet <ClassAndMethod >(10 );
84
84
private boolean returnUnchangedNodes = false ;
@@ -126,12 +126,12 @@ public Configuration withoutProperty(final PropertyPath propertyPath)
126
126
this .excludedProperties .add (propertyPath );
127
127
return this ;
128
128
}
129
-
130
- public Configuration withCompareToOnlyType (final Class <?> type )
131
- {
132
- this .compareToOnlyTypes .add (type );
133
- return this ;
134
- }
129
+
130
+ public Configuration withCompareToOnlyType (final Class <?> type )
131
+ {
132
+ this .compareToOnlyTypes .add (type );
133
+ return this ;
134
+ }
135
135
136
136
public Configuration withEqualsOnlyType (final Class <?> type )
137
137
{
@@ -145,22 +145,25 @@ public Configuration withEqualsOnlyProperty(final PropertyPath propertyPath)
145
145
return this ;
146
146
}
147
147
148
- public Configuration withEqualsOnlyValueProviderMethod (final PropertyPath propertyPath , final String methodName ) {
148
+ public Configuration withEqualsOnlyValueProviderMethod (final PropertyPath propertyPath ,
149
+ final String methodName )
150
+ {
149
151
this .equalsOnlyValueProviderMethods .add (new PropertyPathAndMethod (propertyPath , methodName ));
150
152
return this ;
151
153
}
152
-
153
- public Configuration withEqualsOnlyValueProviderMethod (PropertyPathAndMethod propertyPathEqualsMethod ) {
154
+
155
+ public Configuration withEqualsOnlyValueProviderMethod (final PropertyPathAndMethod propertyPathEqualsMethod )
156
+ {
154
157
this .equalsOnlyValueProviderMethods .add (propertyPathEqualsMethod );
155
158
return this ;
156
159
}
157
-
160
+
158
161
public Configuration withIgnoredNodes ()
159
162
{
160
163
this .returnIgnoredNodes = true ;
161
164
return this ;
162
165
}
163
-
166
+
164
167
public Configuration withoutIgnoredNodes ()
165
168
{
166
169
this .returnIgnoredNodes = false ;
@@ -331,22 +334,24 @@ public boolean isEqualsOnly(final Node node)
331
334
}
332
335
return false ;
333
336
}
334
-
335
- public boolean hasEqualsOnlyValueProviderMethod (Node node ){
336
- return getEqualsOnlyValueProviderMethod (node ) != null ;
337
+
338
+ public boolean hasEqualsOnlyValueProviderMethod (final Node node )
339
+ {
340
+ return Strings .hasText (getEqualsOnlyValueProviderMethod (node ));
337
341
}
338
-
339
- public String getEqualsOnlyValueProviderMethod (Node node ){
342
+
343
+ public String getEqualsOnlyValueProviderMethod (final Node node )
344
+ {
340
345
final Class <?> propertyType = node .getType ();
341
346
if (propertyType != null )
342
347
{
343
- ObjectDiffEqualsOnlyValueProvidedType annotation = propertyType .getAnnotation (ObjectDiffEqualsOnlyValueProvidedType .class );
348
+ final ObjectDiffEqualsOnlyType annotation = propertyType .getAnnotation (ObjectDiffEqualsOnlyType .class );
344
349
if (annotation != null )
345
350
{
346
- return annotation .method ();
351
+ return annotation .valueProviderMethod ();
347
352
}
348
-
349
- ClassAndMethod applicable = findEqualsOnlyValueProviderMethodForClass (propertyType );
353
+
354
+ final ClassAndMethod applicable = findEqualsOnlyValueProviderMethodForClass (propertyType );
350
355
if (applicable != null )
351
356
{
352
357
return applicable .getMethod ();
@@ -356,27 +361,33 @@ public String getEqualsOnlyValueProviderMethod(Node node){
356
361
{
357
362
return node .getEqualsOnlyValueProviderMethod ();
358
363
}
359
- PropertyPathAndMethod applicable = findEqualsOnlyValueProviderMethodForPath (node .getPropertyPath ());
364
+ final PropertyPathAndMethod applicable = findEqualsOnlyValueProviderMethodForPath (node .getPropertyPath ());
360
365
if (applicable != null )
361
366
{
362
367
return applicable .getMethod ();
363
368
}
364
369
return null ;
365
370
}
366
-
367
- private ClassAndMethod findEqualsOnlyValueProviderMethodForClass (Class <?> clazz ){
368
- for (ClassAndMethod propertyPathEqualsOnValueProviderType : equalsOnlyValueProviderTypes ){
369
- if (clazz .equals (propertyPathEqualsOnValueProviderType .getClazz ())){
371
+
372
+ private ClassAndMethod findEqualsOnlyValueProviderMethodForClass (final Class <?> clazz )
373
+ {
374
+ for (final ClassAndMethod propertyPathEqualsOnValueProviderType : equalsOnlyValueProviderTypes )
375
+ {
376
+ if (clazz .equals (propertyPathEqualsOnValueProviderType .getClazz ()))
377
+ {
370
378
return propertyPathEqualsOnValueProviderType ;
371
379
}
372
380
}
373
381
return null ;
374
-
382
+
375
383
}
376
-
377
- private PropertyPathAndMethod findEqualsOnlyValueProviderMethodForPath (PropertyPath propertyPath ){
378
- for (PropertyPathAndMethod propertyPathEqualsOnValueProviderMethod : equalsOnlyValueProviderMethods ){
379
- if (propertyPath .equals (propertyPathEqualsOnValueProviderMethod .getPropertyPath ())){
384
+
385
+ private PropertyPathAndMethod findEqualsOnlyValueProviderMethodForPath (final PropertyPath propertyPath )
386
+ {
387
+ for (final PropertyPathAndMethod propertyPathEqualsOnValueProviderMethod : equalsOnlyValueProviderMethods )
388
+ {
389
+ if (propertyPath .equals (propertyPathEqualsOnValueProviderMethod .getPropertyPath ()))
390
+ {
380
391
return propertyPathEqualsOnValueProviderMethod ;
381
392
}
382
393
}
0 commit comments