if (!hasPin(pin)) {
throw new InvalidPinException(pin);
}
if (!pin.getSupportedPinPullResistance().contains(resistance)) {
throw new UnsupportedPinPullResistanceException(pin, resistance);
}
// cache resistance
getPinCache(pin).setResistance(resistance);
}