VoidValue { @Override public boolean equals(Object obj) { return obj instanceof VoidValue; } VoidValue(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static final VoidValue SINGLETON; }
@Test public void testEquals() throws Exception { Assert.assertTrue(new VoidValue().equals(new VoidValue())); Assert.assertFalse(new VoidValue().equals(new Object())); Assert.assertFalse(new VoidValue().equals(null)); }