in xbean-reflect/src/main/java/org/apache/xbean/recipe/RecipeHelper.java [96:127]
public static boolean isInstance(Type t, Object instance) {
Class type = toClass(t);
if (type.isPrimitive()) {
// for primitives the insance can't be null
if (instance == null) {
return false;
}
// verify instance is the correct wrapper type
if (type.equals(boolean.class)) {
return instance instanceof Boolean;
} else if (type.equals(char.class)) {
return instance instanceof Character;
} else if (type.equals(byte.class)) {
return instance instanceof Byte;
} else if (type.equals(short.class)) {
return instance instanceof Short;
} else if (type.equals(int.class)) {
return instance instanceof Integer;
} else if (type.equals(long.class)) {
return instance instanceof Long;
} else if (type.equals(float.class)) {
return instance instanceof Float;
} else if (type.equals(double.class)) {
return instance instanceof Double;
} else {
throw new AssertionError("Invalid primitve type: " + type);
}
}
return instance == null || type.isInstance(instance);
}