/** * Deep comparison between type and oType. If parameter strictMatch is true, then type and oType will be strictly * compared otherwise this method checks whether oType is assignable from type. */ public final static boolean match(Type type, Type oType, boolean strictMatch) { if (type == null || oType == null) return type == null && oType == null; Class<?> clazz = getRawClass(type); Class<?> oClazz = getRawClass(oType); boolean match = strictMatch ? oClazz.equals(clazz) : oClazz.isAssignableFrom(clazz); if (Object.class.equals(oClazz) && !strictMatch) return match; if (clazz.isArray() && !oClazz.isArray()) return match; Type[] types = getTypes(type); Type[] oTypes = getTypes(oType); match = match && (types.length == oTypes.length || types.length == 0); for (int i = 0; i < types.length && match; i++) match = match(types[i], oTypes[i], strictMatch); return match; }
/** * Deep comparison between type and oType. If parameter strictMatch is true, then type and oType will be strictly * compared otherwise this method checks whether oType is assignable from type. */ public final static boolean match(Type type, Type oType, boolean strictMatch) { if (type == null || oType == null) return type == null && oType == null; Class<?> clazz = getRawClass(type); Class<?> oClazz = getRawClass(oType); boolean match = strictMatch ? oClazz.equals(clazz) : oClazz.isAssignableFrom(clazz); // This means we did expand the best we could and end up with Object, in which case match will be true if oType // is Object too and false otherwise if (Object.class.equals(clazz)) return match; if (Object.class.equals(oClazz) && !strictMatch) return match; if (clazz.isArray() && !oClazz.isArray()) return match; Type[] types = getTypes(type); Type[] oTypes = getTypes(oType); match = match && (types.length == oTypes.length || types.length == 0); for (int i = 0; i < types.length && match; i++) match = match(types[i], oTypes[i], strictMatch); return match; }