Wrapper class for adding elements to HashSet
Why build your own implementation when you can use the features available in the Java standard libraries?

IdentityHashMap gives you all the features you need, and a Java Stream/collector will allow you to extract the map easily from your collection....

Collection&lt;Test&gt; tests = .....
Map&lt;Test,Test&gt; uniques = tests.stream().collect(Collectors.toMap(
     t -&gt; t,
     t -&gt; t,
     (t,u) -&gt; t,
     IdentityHashMap::new))


Now, if the size of the uniques is the same as the tests, you're good. The uniques Map is an IdentityHashMap where the key values are all identical instances (using ==). It supports a null key/value so that should be fine too.