本文整理汇总了Java中org.codehaus.groovy.reflection.ReflectionCache.isAssignableFrom方法的典型用法代码示例。如果您正苦于以下问题:Java ReflectionCache.isAssignableFrom方法的具体用法?Java ReflectionCache.isAssignableFrom怎么用?Java ReflectionCache.isAssignableFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.reflection.ReflectionCache
的用法示例。
在下文中一共展示了ReflectionCache.isAssignableFrom方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isAssignableFrom
import org.codehaus.groovy.reflection.ReflectionCache; //导入方法依赖的package包/类
public static boolean isAssignableFrom(Class classToTransformTo, Class classToTransformFrom) {
if (classToTransformTo == classToTransformFrom
|| classToTransformFrom == null
|| classToTransformTo == Object.class) {
return true;
}
classToTransformTo = ReflectionCache.autoboxType(classToTransformTo);
classToTransformFrom = ReflectionCache.autoboxType(classToTransformFrom);
if (classToTransformTo == classToTransformFrom) return true;
// note: there is no coercion for boolean and char. Range matters, precision doesn't
if (classToTransformTo == Integer.class) {
if (classToTransformFrom == Short.class
|| classToTransformFrom == Byte.class
|| classToTransformFrom == BigInteger.class)
return true;
} else if (classToTransformTo == Double.class) {
if (classToTransformFrom == Integer.class
|| classToTransformFrom == Long.class
|| classToTransformFrom == Short.class
|| classToTransformFrom == Byte.class
|| classToTransformFrom == Float.class
|| classToTransformFrom == BigDecimal.class
|| classToTransformFrom == BigInteger.class)
return true;
} else if (classToTransformTo == BigDecimal.class) {
if (classToTransformFrom == Double.class
|| classToTransformFrom == Integer.class
|| classToTransformFrom == Long.class
|| classToTransformFrom == Short.class
|| classToTransformFrom == Byte.class
|| classToTransformFrom == Float.class
|| classToTransformFrom == BigInteger.class)
return true;
} else if (classToTransformTo == BigInteger.class) {
if (classToTransformFrom == Integer.class
|| classToTransformFrom == Long.class
|| classToTransformFrom == Short.class
|| classToTransformFrom == Byte.class)
return true;
} else if (classToTransformTo == Long.class) {
if (classToTransformFrom == Integer.class
|| classToTransformFrom == Short.class
|| classToTransformFrom == Byte.class)
return true;
} else if (classToTransformTo == Float.class) {
if (classToTransformFrom == Integer.class
|| classToTransformFrom == Long.class
|| classToTransformFrom == Short.class
|| classToTransformFrom == Byte.class)
return true;
} else if (classToTransformTo == Short.class) {
if (classToTransformFrom == Byte.class)
return true;
} else if (classToTransformTo == String.class) {
if (GString.class.isAssignableFrom(classToTransformFrom)) {
return true;
}
}
return ReflectionCache.isAssignableFrom(classToTransformTo, classToTransformFrom);
}
示例2: isAssignableFrom
import org.codehaus.groovy.reflection.ReflectionCache; //导入方法依赖的package包/类
public boolean isAssignableFrom(Class classToTransformFrom) {
return classToTransformFrom == null
|| classToTransformFrom == STRING_CLASS
|| ReflectionCache.isAssignableFrom(GSTRING_CLASS,classToTransformFrom);
}
示例3: isAssignableFrom
import org.codehaus.groovy.reflection.ReflectionCache; //导入方法依赖的package包/类
@Override
public boolean isAssignableFrom(Class argument) {
return argument == null ||
Closure.class.isAssignableFrom(argument) ||
ReflectionCache.isAssignableFrom(getTheClass(), argument);
}