I\'m seeking some clarification to the definition of Value-based Classes. I can\'t imagine, how is the last bullet point (6) supposed to work together with the first one
When you execute the lines:
Optional a = Optional.of(new ArrayList());
Optional b = Optional.of(new ArrayList());
assertEquals(a, b); // passes as `equals` delegated to the lists
In the assertEquals(a, b), according to the API :
a
and b
are both Optional So, when you change one of the ArrayList the Optional instance is pointing to, the assert will fail in the third point.