@Test public void close_safeToCallTwice() throws IOException { Servo servo = new Servo(mPwm); servo.close(); servo.close(); Mockito.verify(mPwm, times(1)).close(); }
@Override public void close() throws IOException { if (mPwm != null) { try { mPwm.close(); } finally { mPwm = null; } } }
Servo implements AutoCloseable { @Override public void close() throws IOException { if (mPwm != null) { try { mPwm.close(); } finally { mPwm = null; } } } }
Servo implements AutoCloseable { @Override public void close() throws IOException { if (mPwm != null) { try { mPwm.close(); } finally { mPwm = null; } } } Servo(String pin);  Servo(String pin, double frequencyHz); @VisibleForTesting  Servo(Pwm device); @VisibleForTesting  Servo(Pwm device, double frequencyHz); }
Servo implements AutoCloseable { @Override public void close() throws IOException { if (mPwm != null) { try { mPwm.close(); } finally { mPwm = null; } } } Servo(String pin);  Servo(String pin, double frequencyHz); @VisibleForTesting  Servo(Pwm device); @VisibleForTesting  Servo(Pwm device, double frequencyHz); @Override void close(); void setEnabled(boolean enabled); void setPulseDurationRange(double minMs, double maxMs); double getMinimumPulseDuration(); double getMaximumPulseDuration(); void setAngleRange(double minAngle, double maxAngle); double getMinimumAngle(); double getMaximumAngle(); void setAngle(double angle); double getAngle(); }
Servo implements AutoCloseable { @Override public void close() throws IOException { if (mPwm != null) { try { mPwm.close(); } finally { mPwm = null; } } } Servo(String pin);  Servo(String pin, double frequencyHz); @VisibleForTesting  Servo(Pwm device); @VisibleForTesting  Servo(Pwm device, double frequencyHz); @Override void close(); void setEnabled(boolean enabled); void setPulseDurationRange(double minMs, double maxMs); double getMinimumPulseDuration(); double getMaximumPulseDuration(); void setAngleRange(double minAngle, double maxAngle); double getMinimumAngle(); double getMaximumAngle(); void setAngle(double angle); double getAngle(); static final double DEFAULT_FREQUENCY_HZ; }