<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="width: 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="width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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|\n"</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;">"|----|----|----|----|----|----|\n"</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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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;">"\n"</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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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="width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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-width: 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>
原文地址:https://mp.weixin.qq.com/s?__biz=MzA3ODQ0Mzg2OA==&mid=2649049711&idx=1&sn=6d874638eea770918a599be2442f77de&chksm=87534e5cb024c74a3c2a0dd792ac1e85ef4c7260235ff029a812300261d230410e418a58f6c0&mpshare=1&scene=23&srcid=06115dzep7FXbo031oAmGRHn#rd