<h1 style="box-sizing: border-box;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 26px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;" data-mpa-powered-by="yiban.io">缘起</h1><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">有一次开发过程中,刚好看到小伙伴在调用 set 方法,将数据库中查询出来的 Po 对象的<strong>属性拷贝</strong>到 Vo 对象中,类似这样:</p><p style="text-align: center;"><img class="rich_pages " data-copyright="0" data-ratio="0.48936170212765956" data-s="300,640" data-type="png" data-w="846" data-src="https://mmbiz.qpic.cn/mmbiz_png/BS5J4xBO9sq6vgxve2QZn7CibSBCH30MMmxicZ1cQbibrEQJicWaialeAKnicCqKkhVH719kOiaibQibh5ZGghmYgzHb7Zw/640?wx_fmt=png" style=" 677px !important; height: auto !important; visibility: visible !important;" _width="677px" src="https://mmbiz.qpic.cn/mmbiz_png/BS5J4xBO9sq6vgxve2QZn7CibSBCH30MMmxicZ1cQbibrEQJicWaialeAKnicCqKkhVH719kOiaibQibh5ZGghmYgzHb7Zw/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" crossorigin="anonymous" data-fail="0"></p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">可以看出,Po 和 Vo 两个类的字段绝大部分是一样的,我们一个个地调用 set 方法只是做了一些重复的冗长的操作。<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">这种操作非常容易出错,因为对象的属性太多,有可能会漏掉一两个,而且肉眼很难察觉</strong>。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">类似这样的操作,我们很容易想到可以通过反射来解决。其实,如此普遍通用的功能,一个 <strong style="box-sizing: border-box;color: rgb(0, 0, 0);">BeanUtils</strong> 工具类就可以搞定了。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">于是我建议这位小伙伴了解一下 BeanUtils,后来他使用了 Apache BeanUtils.copyProperties 进行属性拷贝,这为程序<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">挖了一个坑</strong>!</p><h1 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 26px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">阿里代码规约</h1><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">当我们开启阿里代码扫描插件时,如果你使用了 Apache BeanUtils.copyProperties 进行属性拷贝,它会给你一个<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">非常严重的警告</strong>。因为,<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">Apache BeanUtils性能较差,可以使用 Spring BeanUtils 或者 Cglib BeanCopier 来代替</strong>。</p><p style="text-align: center;"><img class="rich_pages " data-copyright="0" data-ratio="0.33984375" data-s="300,640" data-type="png" data-w="1280" data-src="https://mmbiz.qpic.cn/mmbiz_png/BS5J4xBO9sq6vgxve2QZn7CibSBCH30MMestnARz1PiavibSibic666ztzAMeJaUJrRfYxd0Vf2sFvK8yNEamqpdH6Q/640?wx_fmt=png" style=" 677px !important; height: auto !important; visibility: visible !important;" _width="677px" src="https://mmbiz.qpic.cn/mmbiz_png/BS5J4xBO9sq6vgxve2QZn7CibSBCH30MMestnARz1PiavibSibic666ztzAMeJaUJrRfYxd0Vf2sFvK8yNEamqpdH6Q/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" crossorigin="anonymous" data-fail="0"></p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">看到这样的警告,有点让人有点不爽。大名鼎鼎的 Apache 提供的包,居然会存在<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">性能问题</strong>,以致于阿里给出了严重的警告。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">那么,这个<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">性能问题究竟是有多严重</strong>呢?毕竟,在我们的应用场景中,如果只是很微小的性能损耗,但是能带来非常大的便利性,还是可以接受的。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">带着这个问题。我们来做一个实验,验证一下。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">如果对具体的测试方式没有兴趣,可以<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">跳过直接看结果</strong>哦~</p><h2 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 22px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">测试方法接口和实现定义</h2><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">首先,为了测试方便,让我们来定义一个接口,并提供各种实现:</p><pre class="" style="box-sizing: border-box;padding-top: 8px;padding-bottom: 6px;background: rgb(255, 255, 255);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);text-align: start;font-size: 10px;line-height: 12px;font-family: consolas, menlo, courier, monospace, 'Microsoft Yahei'!important;border- 1px !important;border-style: solid !important;border-color: rgb(226, 226, 226) !important;"><ol class="list-paddingleft-2" style="list-style-type: none;"><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">public interface </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> void copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target) throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">public class </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">CglibBeanCopierPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> implements </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Override</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> public void copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target) throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> copier = </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.create(source.getClass(), target.getClass(), false);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> copier.copy(source, target, null);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 全局静态 BeanCopier,避免每次都生成新的对象</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">public class </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">StaticCglibBeanCopierPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> implements </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> private static </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> copier = </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.create(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Account</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.class, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Account</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.class, false);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Override</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> public void copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target) throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> copier.copy(source, target, null);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">public class </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">SpringBeanUtilsPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> implements </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Override</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> public void copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target) throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> org.springframework.beans.</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanUtils</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.copyProperties(source, target);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">public class </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">CommonsBeanUtilsPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> implements </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Override</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> public void copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target) throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> org.apache.commons.beanutils.</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanUtils</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.copyProperties(target, source);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">public class </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">CommonsPropertyUtilsPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> implements </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Override</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> public void copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target) throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> org.apache.commons.beanutils.</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertyUtils</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.copyProperties(target, source);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">}</span></code></span></p></li></ol></pre><h2 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 22px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">单元测试</h2><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">然后写一个参数化的单元测试:</p><pre class="" style="box-sizing: border-box;padding-top: 8px;padding-bottom: 6px;background: rgb(255, 255, 255);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);text-align: start;font-size: 10px;line-height: 12px;font-family: consolas, menlo, courier, monospace, 'Microsoft Yahei'!important;border- 1px !important;border-style: solid !important;border-color: rgb(226, 226, 226) !important;"><ol class="list-paddingleft-2" style="list-style-type: none;"><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@RunWith</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Parameterized</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.class)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">public class </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopierTest</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Parameterized</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Parameter</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> public </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> propertiesCopier;</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 测试次数</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> private static </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">List</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"><</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Integer</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">> testTimes = </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Arrays</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.asList(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">100</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">1000</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">10</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">_000, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">100</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">_000, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">1_000_000</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 测试结果以 markdown 表格的形式输出</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> private static </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">StringBuilder</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> resultBuilder = new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">StringBuilder</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"|实现|100|1,000|10,000|100,000|1,000,000|
"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">).append(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"|----|----|----|----|----|----|
"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><br></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Parameterized</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Parameters</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> public static </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Collection</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"><</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[]> data() {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Collection</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"><</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[]> params = new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">ArrayList</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"><>();</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> params.add(new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[]{new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">StaticCglibBeanCopierPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">()});</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> params.add(new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[]{new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">CglibBeanCopierPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">()});</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> params.add(new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[]{new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">SpringBeanUtilsPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">()});</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> params.add(new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[]{new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">CommonsPropertyUtilsPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">()});</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> params.add(new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[]{new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">CommonsBeanUtilsPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">()});</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> return params;</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><br></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Before</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> public void setUp() throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">String</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> name = propertiesCopier.getClass().getSimpleName().replace(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"PropertiesCopier"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">""</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> resultBuilder.append(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"|"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">).append(name).append(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"|"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><br></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Test</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> public void copyProperties() throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Account</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source = new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Account</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">1</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"test1"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">30D</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Account</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target = new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Account</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">();</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 预热一次</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> propertiesCopier.copyProperties(source, target);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> for (</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Integer</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> time : testTimes) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> long start = </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">System</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.nanoTime();</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> for (int i = </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; i < time; i++) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> propertiesCopier.copyProperties(source, target);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> resultBuilder.append((</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">System</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.nanoTime() - start) / </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">1_000_000D</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">).append(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"|"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> resultBuilder.append(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"
"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><br></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@AfterClass</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> public static void tearDown() throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">System</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.out.println(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"测试结果:"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">System</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.out.println(resultBuilder);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">}</span></code></span></p></li></ol></pre><h2 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 22px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">测试结果</h2><p style="text-align: center;"><img class="rich_pages " data-ratio="0.3" data-s="300,640" data-type="png" data-w="1280" data-src="https://mmbiz.qpic.cn/mmbiz_png/BS5J4xBO9sq6vgxve2QZn7CibSBCH30MMgJA4icWDJUmNqtAiaiaOtg1UAb80BblK2RDNIKApvcx7B7wjCfrnQ59nw/640?wx_fmt=png" style=" 677px !important; height: auto !important; visibility: visible !important;" _width="677px" src="https://mmbiz.qpic.cn/mmbiz_png/BS5J4xBO9sq6vgxve2QZn7CibSBCH30MMgJA4icWDJUmNqtAiaiaOtg1UAb80BblK2RDNIKApvcx7B7wjCfrnQ59nw/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" crossorigin="anonymous" data-fail="0"></p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">结果表明,<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">Cglib 的 BeanCopier 的拷贝速度是最快的</strong>,即使是百万次的拷贝也只需要 10 毫秒! 相比而言,最差的是 Commons 包的 BeanUtils.copyProperties 方法,100 次拷贝测试与表现最好的 Cglib 相差 <strong style="box-sizing: border-box;color: rgb(0, 0, 0);">400 倍</strong>之多。百万次拷贝更是出现了 <strong style="box-sizing: border-box;color: rgb(0, 0, 0);">2600 倍的性能差异!</strong></p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">结果真是让人大跌眼镜。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">但是它们为什么会有这么大的差异呢?</p><h2 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 22px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">原因分析</h2><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">查看源码,我们会发现 CommonsBeanUtils 主要有以下几个耗时的地方:</p><ul style="list-style-type: square;" class="list-paddingleft-2"><li><p><span style="color: rgb(74, 74, 74);box-sizing: border-box;font-size: 14px !important;">输出了大量的<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">日志</strong>调试信息</span></p></li><li><p><span style="color: rgb(74, 74, 74);box-sizing: border-box;font-size: 14px !important;">重复的对象<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">类型检查</strong></span></p></li><li><p><span style="color: rgb(74, 74, 74);box-sizing: border-box;font-size: 14px !important;"><strong style="box-sizing: border-box;color: rgb(0, 0, 0);">类型转换</strong></span></p></li></ul><pre class="" style="box-sizing: border-box;padding-top: 8px;padding-bottom: 6px;background: rgb(255, 255, 255);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);text-align: start;font-size: 10px;line-height: 12px;font-family: consolas, menlo, courier, monospace, 'Microsoft Yahei'!important;border- 1px !important;border-style: solid !important;border-color: rgb(226, 226, 226) !important;"><ol class="list-paddingleft-2" style="list-style-type: none;"><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> public void copyProperties(final </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> dest, final </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> orig)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">IllegalAccessException</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">InvocationTargetException</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 类型检查 </span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> if (orig instanceof </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">DynaBean</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> } else if (orig instanceof </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Map</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> } else {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> final </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertyDescriptor</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[] origDescriptors = ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> for (</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertyDescriptor</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> origDescriptor : origDescriptors) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 这里每个属性都调一次 copyProperty</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> copyProperty(dest, name, value);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><br></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> public void copyProperty(final </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> bean, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">String</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> name, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> value)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">IllegalAccessException</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">InvocationTargetException</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 这里又进行一次类型检查</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> if (target instanceof </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">DynaBean</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 需要将属性转换为目标类型</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> value = convertForCopy(value, type);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 而这个 convert 方法在日志级别为 debug 的时候有很多的字符串拼接</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> public <T> T convert(final </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Class</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"><T> type, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> value) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> if (log().isDebugEnabled()) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> log().debug(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"Converting"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> + (value == null ? </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">""</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> : </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">" '"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> + toString(sourceType) + </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"'"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">) + </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">" value '"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> + value + </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"' to type '"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> + toString(targetType) + </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"'"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> if (targetType.equals(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">String</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.class)) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> return targetType.cast(convertToString(value));</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> } else if (targetType.equals(sourceType)) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> if (log().isDebugEnabled()) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> log().debug(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"No conversion required, value is already a "</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> + toString(targetType));</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> return targetType.cast(value);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> } else {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 这个 convertToType 方法里也需要做类型检查</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> final </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> result = convertToType(targetType, value);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> if (log().isDebugEnabled()) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> log().debug(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"Converted to "</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> + toString(targetType) + </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">" value '"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> + result + </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"'"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> return targetType.cast(result);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> }</span></code></span></p></li></ol></pre><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">具体的性能和源码分析,可以参考这几篇文章:</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">几种copyProperties工具类性能比较:https://www.jianshu.com/p/bcbacab3b89e </p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">CGLIB中BeanCopier源码实现:https://www.jianshu.com/p/f8b892e08d26 </p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">Java Bean Copy框架性能对比:https://yq.aliyun.com/articles/392185</p><h1 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 26px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">One more thing</h1><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">除了性能问题之外,在使用 CommonsBeanUtils 时还有<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">其他的坑</strong>需要特别小心!</p><h2 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 22px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">包装类默认值</h2><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">在进行属性拷贝时,低版本CommonsBeanUtils 为了解决Date为空的问题会导致为目标对象的<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">原始类型的包装类属性赋予初始值</strong>,如 Integer 属性默认赋值为 0,尽管你的来源对象该字段的值为 null。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">这个在我们的<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">包装类属性为 null 值时有特殊含义的场景</strong>,非常容易踩坑!例如搜索条件对象,一般 null 值表示该字段不做限制,而 0 表示该字段的值必须为0。</p><h2 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 22px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">改用其他工具时</h2><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">当我们看到阿里的提示,或者你看了这篇文章之后,知道了 CommonsBeanUtils 的性能问题,想要改用 Spring 的 BeanUtils 时,<strong>要特别小心</strong>:</p><pre class="" style="box-sizing: border-box;padding-top: 8px;padding-bottom: 6px;background: rgb(255, 255, 255);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);text-align: start;font-size: 10px;line-height: 12px;font-family: consolas, menlo, courier, monospace, 'Microsoft Yahei'!important;border- 1px !important;border-style: solid !important;border-color: rgb(226, 226, 226) !important;"><ol class="list-paddingleft-2" style="list-style-type: none;"><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">org.apache.commons.beanutils.</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanUtils</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border- 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">org.springframework.beans.</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanUtils</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target);</span></code></span></p></li></ol></pre><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">从方法签名上可以看出,这<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">两个工具类的名称相同,方法名也相同,甚至连参数个数、类型、名称都相同</strong>。但是<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">参数的位置是相反的</strong>。因此,如果你想更改的时候,千万要记得,将 target 和 source 两个参数也调换过来!</p>
</div>
大数据基础知识:分布式计算、服务器集群[zz]
weblogic 12c 配置jvm的内存大小
JamCam创业故事:辞掉工作,去开发一个应用
数据挖掘-关联规则分析[ZZ]
十道海量数据处理面试题与十个方法大总结(转载)
设计模式简单说明
jQuery 设置select,radio的值,无法自动触发绑定的change事件
切换node版本,node-sass安装报错
jQuery之编写插件