Pin { @Override public int hashCode() { int result = code != null ? code.hashCode() : 0; result = 31 * result + (path != null ? path.hashCode() : 0); result = 31 * result + (mode != null ? mode.hashCode() : 0); return result; } 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 testHashCode() throws Exception { Pin a = new Pin("P1", new File("/sys/class/gpio/gpio/P1/value"), 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", new File("/sys/class/gpio/gpio/P1/value"), 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.hashCode() == b.hashCode(); }