how to generically compare entire java beans?

后端 未结 4 948
遥遥无期
遥遥无期 2020-12-02 01:58

I\'ve been trying to grok the org.apache.commons.beanutils library for a method/idiom to evaluate for equality all properties between 2 instances i.e. a generic equ

4条回答
  •  执念已碎
    2020-12-02 02:17

    Try EqualsBuilder.reflectionEquals() of commons-lang. EqualsBuilder has a set of methods to include all fields, all non-transient fields and all but certain fields.

    If all else fails, the code could serve as a good example how to implement this.

提交回复
热议问题