ClassUtils.isAssignable(Class<?> lhsType, Class<?> rhsType)

用于判断rhsType类是否能转换为lhsType类

ClassUtils.isAssignable(List.class, ArrayList.class)
//结果为true
 /*** Check if the right-hand side type may be assigned to the left-hand side* type, assuming setting by reflection. Considers primitive wrapper* classes as assignable to the corresponding primitive types.* @param lhsType the target type* @param rhsType the value type that should be assigned to the target type* @return if the target type is assignable from the value type* @see TypeUtils#isAssignable*/public static boolean isAssignable(Class<?> lhsType, Class<?> rhsType) {Assert.notNull(lhsType, "Left-hand side type must not be null");Assert.notNull(rhsType, "Right-hand side type must not be null");// 若左边类型 是右边类型的父类、父接口,或者左边类型等于右边类型if (lhsType.isAssignableFrom(rhsType)) {return true;}// 左边入参是否是基本类型if (lhsType.isPrimitive()) {//primitiveWrapperTypeMap是从包装类型到基本类型的map,将右边入参转化为基本类型Class<?> resolvedPrimitive = primitiveWrapperTypeMap.get(rhsType);if (lhsType == resolvedPrimitive) {return true;}}else {// 将右边入参转化为包装类型Class<?> resolvedWrapper = primitiveTypeToWrapperMap.get(rhsType);if (resolvedWrapper != null && lhsType.isAssignableFrom(resolvedWrapper)) {return true;}}return false;}

Spring ClassUtils.isAssignable相关推荐

  1. Spring源码工具类ClassUtils之isAssignable

    Spring源码工具类ClassUtils之isAssignable 文章目录 Spring源码工具类ClassUtils之isAssignable 一.isAssignable 二.代码示例 一.i ...

  2. Spring-框架-ClassUtils类isAssignable方法

    Spring的isAssignable方法源码: isAssignable方法位于spring的org.springframework.util工具包的ClassUtils类中下 源码: /*** C ...

  3. 我在 Spring 的 BeanUtils 踩到的那些坑,千万不要犯!

    点击关注公众号,Java干货及时送达 转自:绝色天龙 链接:http://www.jianshu.com/p/357b55852efc 背景: 最近项目中在和第三方进行联调一个接口,我们这边发送htt ...

  4. BeanUtils 是用 Spring 的还是 Apache 的好?

    点击上方"方志朋",选择"设为星标" 回复"666"获取新整理的面试文章 来源 | urlify.cn/vUfIry 前言 在我们实际项目开 ...

  5. 两难!到底用Apache BeanUtils还是Spring BeanUtils?

    点击上方"方志朋",选择"设为星标" 回复"666"获取新整理的面试文章 在我们实际项目开发过程中,我们经常需要将不同的两个对象实例进行属性 ...

  6. 对象拷贝 Apache BeanUtils与Spring BeanUtils性能比较

    前言 在我们实际项目开发过程中,我们经常需要将不同的两个对象实例进行属性复制,从而基于源对象的属性信息进行后续操作,而不改变源对象的属性信息,比如DTO数据传输对象和数据对象DO,我们需要将DO对象进 ...

  7. 四条使用Spring BeanUtils的总结

    点击上方蓝色"程序猿DD",选择"设为星标" 回复"资源"获取独家整理的学习资料! 作者 | 绝色天龙 来源 | jianshu.com/p ...

  8. 四条使用Spring BeanUtils的总结,避免各种诡异的属性拷贝问题!

    点击蓝色"程序猿DD"关注我 回复"资源"获取独家整理的学习资料! 作者 | 绝色天龙 来源 | https://www.jianshu.com/p/357b5 ...

  9. 两难!到底用 Spring BeanUtils 还是 Apache BeanUtils?

    前言 在我们实际项目开发过程中,我们经常需要将不同的两个对象实例进行属性复制,从而基于源对象的属性信息进行后续操作,而不改变源对象的属性信息,比如DTO数据传输对象和数据对象DO,我们需要将DO对象进 ...

最新文章

  1. 迁移svn项目到git
  2. Ruby的module(模块)
  3. python——文件操作File
  4. vue_axios详解
  5. TypeScript 编译生成的 JavaScript 源代码里的 ɵcmp 属性
  6. RHEL6.0使用centos的YUM更新源
  7. 浅谈数据库设计技巧(上)
  8. flask web开发是前端还是后端_Flask Web开发实战:入门、进阶与原理解析 PDF 全格式版...
  9. Android 系统(228)---NITZ网络自动对时功能不起作用
  10. java getselecteditem_java – 为什么JComboBox上的getSelectedItem()不是通用的?
  11. 蛋白质结构预测---残基接触的基础知识(二)
  12. 网吧玩吃鸡提示服务器维护,绝地求生游戏更新维护给网吧带来的影响
  13. 输入一个英文星期的前两个字姆,输出中文星期
  14. echarts实现地图飞线
  15. mysql修复主从不一致_MySQL主从不一致修复
  16. 按键精灵---大漠鼠标真实移动轨迹
  17. GB28181平台对接接口详解
  18. mysql 删除重复_MySQL查询和删除重复记录
  19. 蚁群算法解决多峰函数优化问题
  20. 交叉编译详解 - 概念篇

热门文章

  1. 【mysql】日期与时间类型
  2. 如何正确使用Commvault的重复数据删除功能
  3. iNFTnews | NFT带来音乐行业的革命,音乐家和粉丝的互动将更亲密
  4. c++用一级运算比较大小_原神主c角色用谁比较好 主c角色及圣遗物搭配攻略
  5. 深度学习 音乐分类_基于神经网络的音乐流派分类
  6. 厦大纪老师chatgpt相关讲座3.7
  7. Git 介绍 ppt
  8. mov和mp4格式哪个好_在线视频格式转换器哪个好?求一个能转换多种格式的工具_mrxiang...
  9. 玩转南海之滨 广东自助游线路全攻略
  10. 一度智信:拼多多新店如何打造爆品