本文整理匯總了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);
}