public Collection<Binding> wire(Bound bound, BindingContext context, Field field)
throws IllegalAccessException, IntrospectionException {
String target = bound.to();
Mutator mutator = Mutator.create(context, target);
JToggleButton toggle = context.getFieldObject(field, JToggleButton.class);
Class<?>[] paramTypes = mutator.getSetter().getMethod().getParameterTypes();
if (paramTypes.length == 1 && paramTypes[0].isEnum()) {
Class<?> enumType = paramTypes[0];
String value = bound.value();
return ImmutableList.of(bindJToggleButtonToEnum(value, enumType, mutator, toggle));
} else if (paramTypes.length == 1 && paramTypes[0] == boolean.class) {
String value = bound.value();
if (Strings.isNullOrEmpty(value)) {
return ImmutableList.of(AbstractButtonWiringHarness.bindAbstractButton(mutator, toggle));
} else {
return ImmutableList.of(bindJToggleButtonToBoolean(bound.value(), mutator, toggle));
}
} else {
throw new BindingException("can only bind JToggleButtons to enums or booleans");
}
}