'2D java hashsets equality

I implemented a tree representation of temporal logic formulas with equals() and hashCode() methods. I have a 2D hashSet of formulas that are supposed to be equal.

outer:[[(!((p) U (r))) && (!((q) || (p)))], [!(((p) U (r)) || ((q) || (p)))], [!((p) U (r)), !((q) || (p))]].  
clash:[[!((p) U (r)), !((q) || (p))],[(!((p) U (r))) && (!((q) || (p)))], [!(((p) U (r)) || ((q) || (p)))]].  

However, JUnit assertEquals() does not return true. I iterated through the two hashsets and tried contains() with all inner hashsets, and the one that caused the issue is the one with two elements. However, both tests pass when I try the following:

assertEquals(inner.hashCode(), orFormula.getClash2().stream().findFirst().get().hashCode());

and

assertEquals(inner, orFormula.getClash2().stream().findFirst().get());

Is there a way to check if 2D hashsets are equal?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source