@@ -77,9 +77,8 @@ public enum PrimitiveDefaultValueMode
7777 private final Collection <PropertyPath > includedProperties = new HashSet <PropertyPath >(10 );
7878 private final Collection <PropertyPath > excludedProperties = new HashSet <PropertyPath >(10 );
7979 private final Collection <PropertyPath > equalsOnlyProperties = new LinkedHashSet <PropertyPath >(10 );
80+ private final Collection <Class <?>> compareToOnlyTypes = new LinkedHashSet <Class <?>>(10 );
8081 private final Collection <Class <?>> equalsOnlyTypes = new LinkedHashSet <Class <?>>(10 );
81- private final Collection <Class <?>> comparableTypes = new LinkedHashSet <Class <?>>(10 );
82- private final Map <Class <?>, Comparator <?>> compareTypes = new HashMap <Class <?>, Comparator <?>>(10 );
8382 private boolean returnUnchangedNodes = false ;
8483 private boolean returnIgnoredNodes = false ;
8584 private boolean returnCircularNodes = true ;
@@ -126,24 +125,18 @@ public Configuration withoutProperty(final PropertyPath propertyPath)
126125 return this ;
127126 }
128127
128+ public Configuration withCompareToOnlyType (final Class <?> type )
129+ {
130+ this .compareToOnlyTypes .add (type );
131+ return this ;
132+ }
133+
129134 public Configuration withEqualsOnlyType (final Class <?> type )
130135 {
131136 this .equalsOnlyTypes .add (type );
132137 return this ;
133138 }
134139
135- public Configuration withComparableType (final Class <?> type )
136- {
137- this .comparableTypes .add (type );
138- return this ;
139- }
140-
141- public Configuration withCompareType (final Class <?> type , Comparator <?> comparator )
142- {
143- this .compareTypes .put (type , comparator );
144- return this ;
145- }
146-
147140 public Configuration withEqualsOnlyProperty (final PropertyPath propertyPath )
148141 {
149142 this .equalsOnlyProperties .add (propertyPath );
@@ -271,6 +264,23 @@ public boolean isExcluded(final Node node)
271264 return false ;
272265 }
273266
267+ public boolean isCompareToOnly (final Node node )
268+ {
269+ final Class <?> propertyType = node .getType ();
270+ if (propertyType != null )
271+ {
272+ if (compareToOnlyTypes .contains (propertyType ) && Comparable .class .isAssignableFrom (propertyType ))
273+ {
274+ return true ;
275+ }
276+ if (Classes .isComparableType (propertyType ))
277+ {
278+ return true ;
279+ }
280+ }
281+ return false ;
282+ }
283+
274284 public boolean isEqualsOnly (final Node node )
275285 {
276286 final Class <?> propertyType = node .getType ();
@@ -300,7 +310,6 @@ public boolean isEqualsOnly(final Node node)
300310 return false ;
301311 }
302312
303-
304313 public boolean isReturnable (final Node node )
305314 {
306315 if (node .isIgnored ())
@@ -326,21 +335,9 @@ else if (node.hasChildren())
326335 return true ;
327336 }
328337
329- public boolean isComparable (Node node ) {
330- return comparableTypes .contains (node .getType ()) && Comparable .class .isAssignableFrom (node .getType ());
331- }
332-
333338 public boolean isIntrospectible (final Node node )
334339 {
335- if (isEqualsOnly (node ))
336- {
337- return false ;
338- }
339- else if (isComparable (node ))
340- {
341- return false ;
342- }
343- else if (node .isAdded ())
340+ if (node .isAdded ())
344341 {
345342 return returnChildrenOfAddedNodes ;
346343 }
0 commit comments