Linked Questions
16 questions linked to/from Is there a Java utility to do a deep comparison of two objects?
1 vote
0 answers
105 views
Is there an existing Java function that compares two objects via reflection? [duplicate]
Possible Duplicate: Is there a Java reflection utility to do a deep comparison of two objects? I want to create a generic object comparison method like this - public static boolean ...
195 votes
24 answers
239k views
How do I assert equality on two classes without an equals method?
Say I have a class with no equals() method, to which do not have the source. I want to assert equality on two instances of that class. I can do multiple asserts: assertEquals(obj1.getFieldA(), obj2....
14 votes
13 answers
21k views
Assert that two java beans are equivalent
This question is close, but still not what I want. I'd like to assert in a generic way that two bean objects are equivalent. In case they are not, I'd like a detailed error message explaining the ...
23 votes
7 answers
17k views
Check if two objects are completely equal in Java
I've got a Java class, here's an example: public class Car { private int fuelType; private Date made; private String name; . . . // and so on Now let's say I have two car objects and I ...
23 votes
5 answers
33k views
Deep reflective compare equals
I am trying to validate serialize and de-serialize routines by comparing the resulting object with the original object. The routines can serialize arbitrary and deeply nested classes and consequently ...
16 votes
3 answers
13k views
Deep recursive objects comparison (once again)
There are two similar questions on SO: Is there a Java utility to do a deep comparison of two objects? Deep reflective compare equals but, it is funny, none of them gives a fully correct answer to the ...
3 votes
1 answer
6k views
Check objects equality without equals overriding in java [closed]
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....
-1 votes
4 answers
4k views
Compare the return value of a method when expected return type and return value are passed as string parameters
To give a little background on what I am trying to do, please refer my previous question : Run a java method by passing class name and method name as parameter So basically I am trying to call a ...
2 votes
3 answers
1k views
How to compare two values in Java?
I need to compare two objects in Java, but they contain a lot of members, some not visible, and I don't have access to the source code - they're objects from a third-party package. I need to find out ...
2 votes
3 answers
1k views
how to equate two objects in java
Is there a way in which we can equate two objects? I know that we can use equals, but the problem is that I need to write a utility which can compare any two objects implementing same interface. ...
0 votes
2 answers
1k views
Java - Checking Partial Object Equality
I have a use case for filtering a set of objects based on multiple properties of the object. An approach that I would use in Javascript might be to create an object with only the properties that I ...
1 vote
1 answer
921 views
EqualsBuilder using as comparator for attributes
If you know EqualsBuilder from apache commons lang you know that you can use it for implementing equals methods with reflection. It seems to work well but since I am using third party software I need ...
0 votes
1 answer
258 views
Deep Comparision of Two Java Objects
Already referred few question here and there. Use Case - 1.) Given any Two objects, compare both of them property by property. 2.) It will contains Collections also, now compare collections of both ...
0 votes
1 answer
177 views
How to compare two objects( with unsorted value) in java
Object a1= "[{"rdf:resource":"record\/16777228-43386050"},{"rdf:resource":"record\/16777228-43386055"},{"rdf:resource":"record\/16777228-43386057"},{"rdf:resource":"record\/16777228-43386059"}]" ...
0 votes
1 answer
52 views
What's the catch of implementing equals by ObjectOutputStream?
I have a serializable class, that I'd like to compare. It contains many fields and will probably change many times in the future. What are the downsides of implementing equals like this: public class ...