MCPcopy Index your code
hub / github.com/apache/groovy / use

Method use

src/main/java/groovy/lang/ProxyMetaClass.java:104–113  ·  view source on GitHub ↗

Use the ProxyMetaClass for the given Closure. Cares for balanced register/unregister. @param closure piece of code to be executed with registered ProxyMetaClass

(final Closure closure)

Source from the content-addressed store, hash-verified

102 * @param closure piece of code to be executed with registered ProxyMetaClass
103 */
104 public Object use(final Closure closure) {
105 // grab existing meta (usually adaptee but we may have nested use calls)
106 MetaClass origMetaClass = registry.getMetaClass(theClass);
107 registry.setMetaClass(theClass, this);
108 try {
109 return closure.call();
110 } finally {
111 registry.setMetaClass(theClass, origMetaClass);
112 }
113 }
114
115 /**
116 * Use the ProxyMetaClass for the given Closure.

Callers

nothing calls this directly

Calls 3

getMetaClassMethod · 0.65
setMetaClassMethod · 0.65
callMethod · 0.65

Tested by

no test coverage detected