| Method from groovy.lang.Closure Detail: |
public Closure asWritable() {
return new WritableClosure();
}
|
public Object call() {
final Object[] NOARGS = EMPTY_OBJECT_ARRAY;
return call(NOARGS);
}
Invokes the closure without any parameters, returning any value if applicable. |
public Object call(Object[] args) {
try {
return getMetaClass().invokeMethod(this,"doCall",args);
} catch (Exception e) {
return throwRuntimeException(e);
}
}
|
public Object call(Object arguments) {
return call(new Object[]{arguments});
}
Invokes the closure, returning any value if applicable. |
public Object clone() {
try {
return super.clone();
} catch (final CloneNotSupportedException e) {
return null;
}
}
|
public Closure curry(Object[] arguments) {
return new CurriedClosure(this,arguments);
}
Support for closure currying |
public Object getDelegate() {
return this.delegate;
}
|
public int getDirective() {
return directive;
}
|
public int getMaximumNumberOfParameters() {
return maximumNumberOfParameters;
}
|
public Object getOwner() {
return this.owner;
}
|
public Class[] getParameterTypes() {
return parameterTypes;
}
|
public Object getProperty(String property) {
if ("delegate".equals(property)) {
return getDelegate();
} else if ("owner".equals(property)) {
return getOwner();
} else if ("maximumNumberOfParameters".equals(property)) {
return Integer.valueOf(getMaximumNumberOfParameters());
} else if ("parameterTypes".equals(property)) {
return getParameterTypes();
} else if ("metaClass".equals(property)) {
return getMetaClass();
} else if ("class".equals(property)) {
return getClass();
} else if ("directive".equals(property)) {
return Integer.valueOf(getDirective());
} else {
switch(resolveStrategy) {
case DELEGATE_FIRST:
return getPropertyDelegateFirst(property);
case DELEGATE_ONLY:
return InvokerHelper.getProperty(this.delegate, property);
case OWNER_ONLY:
return InvokerHelper.getProperty(this.owner, property);
case TO_SELF:
return super.getProperty(property);
default:
return getPropertyOwnerFirst(property);
}
}
}
|
public int getResolveStrategy() {
return resolveStrategy;
}
Gets the strategy which the closure users to resolve methods and properties |
public Object getThisObject() {
return thisObject;
}
|
public boolean isCase(Object candidate) {
return DefaultTypeTransformation.castToBoolean(call(candidate));
}
|
public void run() {
call();
}
|
public void setDelegate(Object delegate) {
this.delegate = delegate;
}
Allows the delegate to be changed such as when performing markup building |
public void setDirective(int directive) {
this.directive = directive;
}
|
public void setProperty(String property,
Object newValue) {
if ("delegate".equals(property)) {
setDelegate(newValue);
} else if ("metaClass".equals(property)) {
setMetaClass((MetaClass) newValue);
} else if ("resolveStrategy".equals(property)) {
setResolveStrategy(((Number)newValue).intValue());
}
else {
switch(resolveStrategy) {
case DELEGATE_FIRST:
setPropertyDelegateFirst(property, newValue);
break;
case DELEGATE_ONLY:
InvokerHelper.setProperty(this.delegate, property, newValue);
break;
case OWNER_ONLY:
InvokerHelper.setProperty(this.owner, property, newValue);
break;
case TO_SELF:
super.setProperty(property, newValue);
break;
default:
setPropertyOwnerFirst(property, newValue);
}
}
}
|
public void setResolveStrategy(int resolveStrategy) {
this.resolveStrategy = resolveStrategy;
}
Sets the strategy which the closure uses to resolve property references. The default is Closure.OWNER_FIRST |
protected static Object throwRuntimeException(Throwable throwable) {
if (throwable instanceof RuntimeException) {
throw (RuntimeException) throwable;
} else {
throw new GroovyRuntimeException(throwable.getMessage(), throwable);
}
}
|