Comments (3)
Cc: @robfletcher, @lorin
from java-object-diff.
@lorin just pointed out that this may be a duplicate of #96
from java-object-diff.
比较两个集合对象, 会执行de.danielbechler.diff.differ.CollectionDiffer
比较器逻辑:
- 遍历working集合中的每个元素, 如果不存在于base集合中, 则认为working集合新增了元素
- 遍历base集合中的每个元素, 如果不存在于working集合中, 则认为working集合删除了元素
- 元素同时存在于两个集合中, 才会继续比较每个属性的值, 这种情况你的配置才会生效
关键代码:
de.danielbechler.diff.differ.CollectionDiffer#compareInternally
de.danielbechler.diff.access.CollectionItemAccessor#get
de.danielbechler.diff.identity.EqualsIdentityStrategy#equals
判断集合中元素是否相同, 默认调用对象的equals
方法, 基于此, 提供两种解决办法:
- 可以重写数据类的
equals
和hashCode
方法, 忽略添加ExcludedFromDiff
注解的字段 - 自定义并配置
IdentityStrategy
from java-object-diff.
Related Issues (20)
- Javadoc build errors
- Is ObjectDiffer thread safe and non-stateful?
- Suggestion: Put element index in CollectionItemElementSelector HOT 3
- How to exclude map key HOT 1
- OSGi MANIFEST.MF is broken for version 0.95
- Exclude the properties market as _metadata_ HOT 7
- java.time.LocalTime not working
- How to get the difference between two simple objects? HOT 4
- java基本类型boolean比较有问题,只有ADD或者DELETE。其中EDIT出现不了 HOT 1
- compare wrongly returns UNTOUCHED
- How to apply diffs
- How to exclude property of a collection of specific type
- How to get diff of child Object ? HOT 1
- Can't Find Setter For Property While Using lombok HOT 1
- Problem with circular references
- PrintingVisitor should print only the relevant fields of a CollectionItemElementSelector
- java8 LocalDateTime is not supported HOT 1
- llegalStateException: Couldn't find a differ for type: [Lorg.joda.time.DateTimeFieldType
- can add @ObjectDiffProperty use to class field?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-object-diff.