问题
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