public static Object dispatchSetterStyle(String property, DynamicObject object, Object arg) throws Throwable {
Object value = object.get(property);
if (value != null || object.properties.containsKey(property)) {
if (value instanceof MethodHandle) {
MethodHandle handle = (MethodHandle) value;
if (handle.type().parameterCount() == 2) {
if (handle.isVarargsCollector() && arg instanceof Object[]) {
return handle.invokeExact((Object) object, (Object[]) arg);
}
return handle.invokeWithArguments(object, arg);
}