@Test public void close_safeToCallTwice() throws IOException { mDriver.close(); mDriver.close(); verify(mI2c, times(1)).close(); }
@Override public void close() throws IOException { if (mI2cDevice != null) { try { mI2cDevice.close(); } finally { mI2cDevice = null; } } }
MotorHat implements AutoCloseable { @Override public void close() throws IOException { if (mI2cDevice != null) { try { mI2cDevice.close(); } finally { mI2cDevice = null; } } } }
MotorHat implements AutoCloseable { @Override public void close() throws IOException { if (mI2cDevice != null) { try { mI2cDevice.close(); } finally { mI2cDevice = null; } } } MotorHat(String i2cBusName);  MotorHat(String i2cBusName, int i2cAddress); @VisibleForTesting  MotorHat(I2cDevice device); }
MotorHat implements AutoCloseable { @Override public void close() throws IOException { if (mI2cDevice != null) { try { mI2cDevice.close(); } finally { mI2cDevice = null; } } } MotorHat(String i2cBusName);  MotorHat(String i2cBusName, int i2cAddress); @VisibleForTesting  MotorHat(I2cDevice device); @Override void close(); void setMotorSpeed(int motor, int speed); void setMotorState(int motor, @MotorState int state); }
MotorHat implements AutoCloseable { @Override public void close() throws IOException { if (mI2cDevice != null) { try { mI2cDevice.close(); } finally { mI2cDevice = null; } } } MotorHat(String i2cBusName);  MotorHat(String i2cBusName, int i2cAddress); @VisibleForTesting  MotorHat(I2cDevice device); @Override void close(); void setMotorSpeed(int motor, int speed); void setMotorState(int motor, @MotorState int state); static final int DEFAULT_I2C_ADDRESS; static final int MOTOR_STATE_RELEASE; static final int MOTOR_STATE_CW; static final int MOTOR_STATE_CCW; }