protected Type[] getDictionaryTypes(Class<?> type, Type genericType) { Type[] types = Types.getTypeArguments(genericType); if(types.length != 2) { for(Type genericInterface : type.getGenericInterfaces()) { Class<?> c = Types.getActualType(genericInterface); if(Map.class.isAssignableFrom(c)) { return getDictionaryTypes(c, genericInterface); } } Type genericSuperClass = type.getGenericSuperclass(); if(null != genericSuperClass) { Class<?> c = Types.getActualType(genericSuperClass); if(Map.class.isAssignableFrom(c)) { return getDictionaryTypes(c, genericSuperClass); } } } return types; }
protected MType getDictionaryType(MTypeContext context, Class<?> declaringType, Class<?> type, Type genericType, MTypeFactory root) { if(null == genericType) { return MDictionaryType.INSTANCE; } Type[] types = getDictionaryTypes(type, genericType); Type keyType = types[0]; Type valType = types[1]; MType keyMType = getMType(context, declaringType, Types.getActualType(keyType), keyType, root); MType valMType = getMType(context, declaringType, Types.getActualType(valType), valType, root); return new MDictionaryType(keyMType, valMType); }