use of org.gradle.internal.metaobject.BeanDynamicObject in project gradle by gradle.
the class MixInClosurePropertiesAsMethodsDynamicObject method tryInvokeMethod.
@Override
public DynamicInvokeResult tryInvokeMethod(String name, Object... arguments) {
DynamicInvokeResult result = super.tryInvokeMethod(name, arguments);
if (result.isFound()) {
return result;
}
DynamicInvokeResult propertyResult = tryGetProperty(name);
if (propertyResult.isFound()) {
Object property = propertyResult.getValue();
if (property instanceof Closure) {
Closure closure = (Closure) property;
closure.setResolveStrategy(Closure.DELEGATE_FIRST);
BeanDynamicObject dynamicObject = new BeanDynamicObject(closure);
result = dynamicObject.tryInvokeMethod("doCall", arguments);
if (!result.isFound() && !(closure instanceof GeneratedClosure)) {
return DynamicInvokeResult.found(closure.call(arguments));
}
return result;
}
if (property instanceof NamedDomainObjectContainer && arguments.length == 1 && arguments[0] instanceof Closure) {
((NamedDomainObjectContainer) property).configure((Closure) arguments[0]);
return DynamicInvokeResult.found();
}
}
return DynamicInvokeResult.notFound();
}
Aggregations