Check objects equality without equals overriding in java [closed]

∥☆過路亽.° 提交于 2019-12-20 02:56:31

问题


Are there any utils in java which allow to check objects equality without equals overriding? For some reasons I don't want to provide my class with equals method. I need something like SomeUtils.equals(a,b) in my unit test which compares all object fields (via reflection I guess).


回答1:


You could use EqualsBuilder.reflectionEquals(this, obj); in Apache Commons EqualsBuilder



来源:https://stackoverflow.com/questions/30195291/check-objects-equality-without-equals-overriding-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!