本文整理汇总了Java中org.codehaus.groovy.runtime.MetaClassHelper.convertToTypeArray方法的典型用法代码示例。如果您正苦于以下问题:Java MetaClassHelper.convertToTypeArray方法的具体用法?Java MetaClassHelper.convertToTypeArray怎么用?Java MetaClassHelper.convertToTypeArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.runtime.MetaClassHelper
的用法示例。
在下文中一共展示了MetaClassHelper.convertToTypeArray方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNormalMethodWithCaching
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
private MetaMethod getNormalMethodWithCaching(Object[] arguments, MetaMethodIndex.Entry e) {
MetaMethodIndex.CacheEntry cacheEntry;
final Object methods = e.methods;
if (methods == null)
return null;
cacheEntry = e.cachedMethod;
if (cacheEntry != null &&
MetaClassHelper.sameClasses(cacheEntry.params, arguments, methods instanceof MetaMethod))
{
MetaMethod method = cacheEntry.method;
if (method!=null) return method;
}
final Class[] classes = MetaClassHelper.convertToTypeArray(arguments);
cacheEntry = new MetaMethodIndex.CacheEntry (classes, (MetaMethod) chooseMethod(e.name, methods, classes));
e.cachedMethod = cacheEntry;
return cacheEntry.method;
}
示例2: retrieveStaticMethod
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
public MetaMethod retrieveStaticMethod(String methodName, Object[] arguments) {
final MetaMethodIndex.Entry e = metaMethodIndex.getMethods(theClass, methodName);
MetaMethodIndex.CacheEntry cacheEntry;
if (e != null) {
cacheEntry = e.cachedStaticMethod;
if (cacheEntry != null &&
MetaClassHelper.sameClasses(cacheEntry.params, arguments, e.staticMethods instanceof MetaMethod))
{
return cacheEntry.method;
}
final Class[] classes = MetaClassHelper.convertToTypeArray(arguments);
cacheEntry = new MetaMethodIndex.CacheEntry (classes, pickStaticMethod(methodName, classes));
e.cachedStaticMethod = cacheEntry;
return cacheEntry.method;
}
else
return pickStaticMethod(methodName, MetaClassHelper.convertToTypeArray(arguments));
}
示例3: 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;
}
示例4: 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;
}
示例5: 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) + ")");
}
示例6: createPogoCallSite
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
/**
* Create a CallSite
*/
public CallSite createPogoCallSite(CallSite site, Object[] args) {
if (!GroovyCategorySupport.hasCategoryInCurrentThread() && !(this instanceof AdaptingMetaClass)) {
Class [] params = MetaClassHelper.convertToTypeArray(args);
CallSite tempSite = site;
if (site.getName().equals("call") && GeneratedClosure.class.isAssignableFrom(theClass)) {
// here, we want to point to a method named "doCall" instead of "call"
// but we don't want to replace the original call site name, otherwise
// we loose the fact that the original method name was "call" so instead
// we will point to a metamethod called "doCall"
// see GROOVY-5806 for details
tempSite = new AbstractCallSite(site.getArray(),site.getIndex(),"doCall");
}
MetaMethod metaMethod = getMethodWithCachingInternal(theClass, tempSite, params);
if (metaMethod != null)
return PogoMetaMethodSite.createPogoMetaMethodSite(site, this, metaMethod, params, args);
}
return new PogoMetaClassSite(site, this);
}
示例7: createPojoCallSite
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
/**
* Create a CallSite
*/
public CallSite createPojoCallSite(CallSite site, Object receiver, Object[] args) {
if (!(this instanceof AdaptingMetaClass)) {
Class [] params = MetaClassHelper.convertToTypeArray(args);
MetaMethod metaMethod = getMethodWithCachingInternal(getTheClass(), site, params);
if (metaMethod != null)
return PojoMetaMethodSite.createPojoMetaMethodSite(site, this, metaMethod, params, receiver, args);
}
return new PojoMetaClassSite(site, this);
}
示例8: createStaticSite
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
/**
* Create a CallSite
*/
public CallSite createStaticSite(CallSite site, Object[] args) {
if (!(this instanceof AdaptingMetaClass)) {
Class [] params = MetaClassHelper.convertToTypeArray(args);
MetaMethod metaMethod = retrieveStaticMethod(site.getName(), args);
if (metaMethod != null)
return StaticMetaMethodSite.createStaticMetaMethodSite(site, this, metaMethod, params, args);
}
return new StaticMetaClassSite(site, this);
}
示例9: createPogoCallCurrentSite
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
/**
* Create a CallSite
*/
public CallSite createPogoCallCurrentSite(CallSite site, Class sender, Object[] args) {
if (!GroovyCategorySupport.hasCategoryInCurrentThread() && !(this instanceof AdaptingMetaClass)) {
Class [] params = MetaClassHelper.convertToTypeArray(args);
MetaMethod metaMethod = getMethodWithCachingInternal(sender, site, params);
if (metaMethod != null)
return PogoMetaMethodSite.createPogoMetaMethodSite(site, this, metaMethod, params, args);
}
return new PogoMetaClassSite(site, this);
}
示例10: createConstructorSite
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
/**
* Create a CallSite
*/
public CallSite createConstructorSite(CallSite site, Object[] args) {
if (!(this instanceof AdaptingMetaClass)) {
Class[] params = MetaClassHelper.convertToTypeArray(args);
CachedConstructor constructor = (CachedConstructor) chooseMethod("<init>", constructors, params);
if (constructor != null) {
return ConstructorSite.createConstructorSite(site, this,constructor,params, args);
}
else {
if (args.length == 1 && args[0] instanceof Map) {
constructor = (CachedConstructor) chooseMethod("<init>", constructors, MetaClassHelper.EMPTY_TYPE_ARRAY);
if (constructor != null) {
return new ConstructorSite.NoParamSite(site, this,constructor,params);
}
} else if (args.length == 2 && theClass.getEnclosingClass() != null && args[1] instanceof Map) {
Class enclosingClass = theClass.getEnclosingClass();
String enclosingInstanceParamType = args[0] != null ? args[0].getClass().getName() : "";
if(enclosingClass.getName().equals(enclosingInstanceParamType)) {
constructor = (CachedConstructor) chooseMethod("<init>", constructors, new Class[]{enclosingClass});
if (constructor != null) {
return new ConstructorSite.NoParamSiteInnerClass(site, this,constructor,params);
}
}
}
}
}
return new MetaClassConstructorSite(site, this);
}
示例11: invokeConstructor
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
public Object invokeConstructor(Object[] arguments) {
// TODO This is the only area where this MetaClass needs to do some interception because Groovy's current
// MetaClass uses hard coded references to the java.lang.reflect.Constructor class so you can't simply
// inject Constructor like you can do properties, methods and fields. When Groovy's MetaClassImpl is
// refactored we can fix this
Class[] argClasses = MetaClassHelper.convertToTypeArray(arguments);
MetaMethod method = pickMethod(GROOVY_CONSTRUCTOR, argClasses);
if (method != null && method.getParameterTypes().length == arguments.length) {
return method.invoke(theClass, arguments);
}
return super.invokeConstructor(arguments);
}
示例12: retrieveConstructor
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
@Override
public MetaMethod retrieveConstructor(Object[] args) {
Class[] params = MetaClassHelper.convertToTypeArray(args);
MetaMethod method = pickMethod(GROOVY_CONSTRUCTOR, params);
if (method!=null) return method;
return super.retrieveConstructor(args);
}
示例13: createConstructorSite
import org.codehaus.groovy.runtime.MetaClassHelper; //导入方法依赖的package包/类
public CallSite createConstructorSite(CallSite site, Object[] args) {
Class[] params = MetaClassHelper.convertToTypeArray(args);
MetaMethod method = pickMethod(GROOVY_CONSTRUCTOR, params);
if (method != null && method.getParameterTypes().length == args.length) {
if (method.getDeclaringClass().getTheClass().equals(getTheClass())) {
return new ConstructorMetaMethodSite(site, this, method, params);
}
}
return super.createConstructorSite(site, args);
}