 <p>This is the concept of <a href="http://docs.oracle.com/javase/tutorial/reflect/" rel="nofollow">Reflection</a>. You should be able to do something like the following (untested) code snippet:</p> <pre><code>/** * @return {@code true} if all of the values of the fields in {@code obj} are * contained in the set of {@code values}; {@code false} otherwise. */ public boolean containsAllValues(HashSet&lt;Object&gt; values, MyClass obj) { Field[] fields = MyClass.class.getFields(); for (Field field : fields) { Object fieldValue = field.get(obj); if (values.contains(fieldValue)) { return false; } } return true; } </code></pre>