本文整理汇总了Java中org.codehaus.groovy.runtime.MetaClassHelper.unwrap方法的典型用法代码示例。如果您正苦于以下问题:Java MetaClassHelper.unwrap方法的具体用法?Java MetaClassHelper.unwrap怎么用?Java MetaClassHelper.unwrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.runtime.MetaClassHelper
的用法示例。
在下文中一共展示了MetaClassHelper.unwrap方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCachedConstructor
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
private CachedConstructor createCachedConstructor(Object[] arguments) {
if (arguments == null) arguments = EMPTY_ARGUMENTS;
Class[] argClasses = MetaClassHelper.convertToTypeArray(arguments);
MetaClassHelper.unwrap(arguments);
CachedConstructor constructor = (CachedConstructor) chooseMethod("<init>", constructors, argClasses);
if (constructor == null) {
constructor = (CachedConstructor) chooseMethod("<init>", constructors, argClasses);
}
if (constructor == null) {
throw new GroovyRuntimeException(
"Could not find matching constructor for: "
+ theClass.getName()
+ "(" + InvokerHelper.toTypeString(arguments) + ")");
}
return constructor;
}
示例2: retrieveConstructor
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
/**
* This is a helper method added in Groovy 2.1.0, which is used only by indy.
* This method is for internal use only.
* @since Groovy 2.1.0
*/
public MetaMethod retrieveConstructor(Object[] arguments) {
checkInitalised();
if (arguments == null) arguments = EMPTY_ARGUMENTS;
Class[] argClasses = MetaClassHelper.convertToTypeArray(arguments);
MetaClassHelper.unwrap(arguments);
Object res = chooseMethod("<init>", constructors, argClasses);
if (res instanceof MetaMethod) return (MetaMethod) res;
CachedConstructor constructor = (CachedConstructor) res;
if (constructor != null) return new MetaConstructor(constructor, false);
if (arguments.length == 1 && arguments[0] instanceof Map) {
res = chooseMethod("<init>", constructors, MetaClassHelper.EMPTY_TYPE_ARRAY);
} else if (
arguments.length == 2 && arguments[1] instanceof Map &&
theClass.getEnclosingClass()!=null &&
theClass.getEnclosingClass().isAssignableFrom(argClasses[0]))
{
res = chooseMethod("<init>", constructors, new Class[]{argClasses[0]});
}
if (res instanceof MetaMethod) return (MetaMethod) res;
constructor = (CachedConstructor) res;
if (constructor != null) return new MetaConstructor(constructor, true);
return null;
}
示例3: invokeConstructor
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
private Object invokeConstructor(Class at, Object[] arguments) {
checkInitalised();
if (arguments == null) arguments = EMPTY_ARGUMENTS;
Class[] argClasses = MetaClassHelper.convertToTypeArray(arguments);
MetaClassHelper.unwrap(arguments);
CachedConstructor constructor = (CachedConstructor) chooseMethod("<init>", constructors, argClasses);
if (constructor != null) {
return constructor.doConstructorInvoke(arguments);
}
if (arguments.length == 1) {
Object firstArgument = arguments[0];
if (firstArgument instanceof Map) {
constructor = (CachedConstructor) chooseMethod("<init>", constructors, MetaClassHelper.EMPTY_TYPE_ARRAY);
if (constructor != null) {
Object bean = constructor.doConstructorInvoke(MetaClassHelper.EMPTY_ARRAY);
setProperties(bean, ((Map) firstArgument));
return bean;
}
}
}
throw new GroovyRuntimeException(
"Could not find matching constructor for: "
+ theClass.getName()
+ "(" + InvokerHelper.toTypeString(arguments) + ")");
}
示例4: invoke
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
public final Object invoke(Object receiver, Object [] args) throws Throwable{
MetaClassHelper.unwrap(args);
try {
return metaMethod.doMethodInvoke(metaClass.getTheClass(), args);
} catch (GroovyRuntimeException gre) {
throw ScriptBytecodeAdapter.unwrap(gre);
}
}
示例5: callConstructor
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
public final Object callConstructor(Object receiver, Object[] args) throws Throwable {
if (receiver == metaClass.getTheClass() // meta class match receiver
&& ((MetaClassImpl)metaClass).getVersion() == version // metaClass still be valid
&& MetaClassHelper.sameClasses(params, args) )
{
MetaClassHelper.unwrap(args);
try {
return metaMethod.doMethodInvoke(metaClass.getTheClass(), args);
} catch (GroovyRuntimeException gre) {
throw ScriptBytecodeAdapter.unwrap(gre);
}
} else {
return CallSiteArray.defaultCallConstructor(this, receiver, args);
}
}
示例6: invoke
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
public Object invoke(Object receiver, Object[] args) throws Throwable {
MetaClassHelper.unwrap(args);
try {
return metaMethod.doMethodInvoke(receiver, args);
} catch (GroovyRuntimeException gre) {
throw ScriptBytecodeAdapter.unwrap(gre);
}
}
示例7: invoke
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
public Object invoke(Object receiver, Object[] args) throws Throwable {
MetaClassHelper.unwrap(args);
args = metaMethod.coerceArgumentsToClasses(args);
try {
return reflect.invoke(receiver, args);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof GroovyRuntimeException) {
throw ScriptBytecodeAdapter.unwrap ((GroovyRuntimeException) cause);
} else {
throw cause;
}
}
}
示例8: callConstructor
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
public Object callConstructor(Object receiver, Object[] args) throws Throwable {
if (checkCall(receiver, args)) {
MetaClassHelper.unwrap(args);
try {
return constructor.doConstructorInvoke(args);
} catch (GroovyRuntimeException gre) {
throw ScriptBytecodeAdapter.unwrap(gre);
}
} else
return CallSiteArray.defaultCallConstructor(this, receiver, args);
}
示例9: invokeMethod
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
/**
* Overrides default implementation just in case invokeMethod has been overridden by ExpandoMetaClass
*
* @see groovy.lang.MetaClassImpl#invokeMethod(Class, Object, String, Object[], boolean, boolean)
*/
public Object invokeMethod(Class sender, Object object, String methodName, Object[] originalArguments, boolean isCallToSuper, boolean fromInsideClass) {
if (invokeMethodMethod != null) {
MetaClassHelper.unwrap(originalArguments);
return invokeMethodMethod.invoke(object, new Object[]{methodName, originalArguments});
}
return super.invokeMethod(sender, object, methodName, originalArguments, isCallToSuper, fromInsideClass);
}
示例10: invokeStaticMethod
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
/**
* Overrides default implementation just in case a static invoke method has been set on ExpandoMetaClass
*
* @see MetaClassImpl#invokeStaticMethod(Object, String, Object[])
*/
public Object invokeStaticMethod(Object object, String methodName, Object[] arguments) {
if (invokeStaticMethodMethod != null) {
MetaClassHelper.unwrap(arguments);
return invokeStaticMethodMethod.invoke(object, new Object[]{methodName, arguments});
}
return super.invokeStaticMethod(object, methodName, arguments);
}