if(!pin.getProvider().isShutdown()){
pin.getProvider().shutdown();
}
// perform the shutdown options if configured for the pin
GpioPinShutdown shutdownOptions = pin.getShutdownOptions();
if (shutdownOptions != null) {
// get shutdown option configuration
PinState state = shutdownOptions.getState();
PinMode mode = shutdownOptions.getMode();
PinPullResistance resistance = shutdownOptions.getPullResistor();
Boolean unexport = shutdownOptions.getUnexport();
// perform shutdown actions
if ((state != null) && (pin instanceof GpioPinDigitalOutput)) {
((GpioPinDigitalOutput)pin).setState(state);
}