Pin { @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Pin)) return false; Pin pin = (Pin) o; if (code != null ? !code.equals(pin.code) : pin.code != null) return false; if (path != null ? !path.equals(pin.path) : pin.path != null) return false; return mode == pin.mode; } Pin(String code, Mode mode, PinCommand command);  Pin(String code, File path, Mode mode, PinCommand command);  Pin(String code, PinCommand command);  Pin(String code, File path, PinCommand command); String getCode(); File getPath(); Mode getMode(); void setMode(Mode mode); void write(boolean value); boolean read(); void enable(); void disable(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean isEnabled();  }
@Test public void testEquals() throws Exception { Pin a = new Pin("P1", Pin.Mode.IN, new TestPinCommand() { @Override public Pin.Mode getMode(Pin pin) throws PinCommandException { return Pin.Mode.IN; } @Override public boolean read(Pin pin) throws PinCommandException { return true; } }); Pin b = new Pin("P1", Pin.Mode.IN, new TestPinCommand() { @Override public Pin.Mode getMode(Pin pin) throws PinCommandException { return Pin.Mode.IN; } @Override public boolean read(Pin pin) throws PinCommandException { return true; } }); assert !a.equals(null); assert a.equals(b); }