- Comparison: Values of different types will now be compared via
equals
method instead of causing an exception. #162 - DiffNode: DiffNodes now return all configured categories instead of just the ones fron the annotation. #160
- Introspection: The
StandardIntrospector
will now only be created when needed, so platforms like Android (wherejava.beans.Introspector
is not available) can easily provide alternative implementations. #158 - Maintenance: Fully replaced TestNG, Mockito and FestAssert with Spock.
- Maintenance: Added Eclipse files to .gitignore #153
- Maintenance: Fixed typo in JavaDoc of CircularReferenceConfigurer #154
Big thanks to @jlsalmon, @scompo, @simplysoft & @PascalSchumacher for your contributions!
- Fixes a memory leak when the
ObjectDiffer
throws an exception
- Comparison: Fixed a concurrency issue when sharing the ObjectDiffer between multiple threads. Thanks @tacoo
-
Comparison: The
ObjectDifferBuilder
now provides new configuration outlet calledidentity
This allows for providing a custom strategy to establish the identity of collection items base on something other than the equals method. That's especially useful when you have no control over the items equals and hashCode methods.
However, it's a brand-new feature and there may be some corner-cases that have not yet been anticipated. If you run into any trouble using this feature, please feel free to open a ticket in the issue tracker.
Many thanks to @NagyGa1 for his help on this feature.
-
ElementSelector:
CollectionItemElementSelector
now returns a constant hashCode...instead of the one of its reference item.
The ElementSelector
hashCode
is only needed to use it as key in a Map. With introduction of theIdentityStrategy
this adds an unnecessary source of confusion and complexity when implementing custom IdentityStrategies.To avoid this, returning a constant hashCode seems like a small price to pay. Yes, it may have a small performance impact, but we can still optimize when that turns out to be a problem.
- Feature: Allow for checking field level annotations via DiffNode (Thanks @NagyGa1) [#134]
-
Comparison: Enable ComparableComparisonStrategy for more types
So far this strategy only applied to BigDecimals. It has now been extended to automatically apply to all simple types that implement
java.lang.Comparable
.The list of types that qualify as simple has also been extended. It now looks as follows:
- all primitive types (int, short, byte, etc.)
- all primitive wrapper types (Integer, Short, Byte, etc.)
- enums
- subclasses of:
java.math.BigDecimal
java.math.BigInteger
java.lang.CharSequence
java.util.Calendar
java.util.Date
java.lang.Class
java.net.URI
java.net.URL
java.util.Locale
java.util.UUID
Of course this behaviour can be overriden via configuration API or property annotations.
To make comparison via
compareTo
more reliable, from now oncompareTo
will be invoked on theworking
and thebase
object and both will be considered equal if either one of this comparisons returnstrue
. -
Comparison: Dates are now compared via compareTo method to workaround the strictness of java.util.Date's equals method, which only returns true for other java.util.Dates, but not for extending classes like java.sql.Date. [#85]
-
DiffNode: Replaced some constructors with factory methods to better express their intentions.
-
Utilities: Removed some unused collection utility methods.
-
Tests: Migrated many, many more tests from TestNG to Spock.
-
Tests: Upgraded to Groovy 2.3 and Spock 1.0.
- Exception Handling: Reimplemented property access exception handling
- Inclusion: Implemented a mechanism to control the inclusion of properties of specific object types.
- Inclusion: Implemented a mechanism to register custom inclusion resolvers to support inclusion rules far beyond the built-in ones.
- Introspection: Implemented a mechanism to register a custom instance factory, which is used by
DiffNode#canonicalSet
in order to create instances of missing objects
- Inclusion: Performance improvements (Thanks @Deipher)
- Inclusion:
InclusionService
has been split into severalInclusionResolver
s - DiffNode:
canonicalSet
now automatically creates missing objects along the path to the root object
- Circular Reference Detection: Fixed 'Detected inconsistency in enter/leave sequence. Must always be LIFO.' bug that could occur due to inconsistent cleanup of the instance memory when a circular reference has been detected.
-
[#66] The signature of compared objects is now determined at runtime whenever possible. The signature of bean property values used to simply be the one of its getters return type. The object differ now does its best to determine the most specific shared object type. It does this like so:
- If the object types of base and working are the same, the signature of this type will be used for introspection. (1)
- If the object types of base and working are different, the signature of their closest shared superclass will be used. (2)
- If no shared superclass could be found, it falls back the the declared return type of the objects property getter. (3)
The runtime type analysis will not consider shared interfaces, so the only way to diff exclusively against interface signatures, is to cause the type lookup to fall through to (3). Currently I'm not sure if it needs to be possible to force the object differ to always use the declared type. If you think it does or this new behavior causes you any trouble, please let me know.
- Fixed Java 5 incompatibility (replaced
Deque
withLinkedList
)
- Added Maven Plugin to verify Java 5 API compatibility
- Added a method to
PropertyNode
to return all annotations of its accessor [#46] - Circular nodes now provide access to the node where the circle started [#52]
- Allowed to configure the way circular references are detected. Objects can now either be matched as usual via equality operator or alternatively via equals method
- Added an example to demonstrate the difference between
Node#get(Object)
andNode#canonicalGet(Object)
- Lowered minimum required Java version from Java 6 to 5 [#51]
- The library is now packaged in an OSGi-compliant way [#53]
- Fixed a bug that caused
Maps
andCollections
to be improperly compared in case they were configured to use the equals only comparison strategy
- Major refactoring of most core classes to allow for better extendability and testability
- Increased test coverage
- Added some more code examples
- Upgraded to latest versions of SLF4J, Mockito and TestNG
- Ignored properties will no longer be accessed (regression)
- Starting from this release
java-object-diff
will be available via Maven Central repository
logback.xml
is no longer included in the JAR file
- It is now possible to retrieve the property graph of added and removed nodes
- Collections and Maps of different types can now be properly compared
- Added configuration option to allow primitive default values to be treated like
null
objects or regular values
- Switched from JUnit to TestNG
- Accessors now have a neat toString representation
- Changed output format of printing visitors a little bit
- The
ADDED
andREMOVED
state of object nodes is now simplynull
based (default values won't be taken into account anymore) - Private constructors can now be accessed to determine the default values of primitive properties
- Primitive types are now handled in a more intuitive way