import{_ as s,o as n,c as a,e as l}from"./app.87c2e303.js";const p={},o=l(`<h1 id="\u5C55\u671B\u672A\u6765" tabindex="-1"><a class="header-anchor" href="#\u5C55\u671B\u672A\u6765" aria-hidden="true">#</a> \u5C55\u671B\u672A\u6765</h1><blockquote><p>\u672A\u6765\u662F\u7F8E\u597D\u7684\uFF0C\u4E5F\u662F\u4E0D\u786E\u5B9A\u7684\uFF0C\u8BA9\u6211\u4EEC\u5171\u540C\u671F\u5F85 <code>YukiReflection</code> \u5728\u672A\u6765\u7684\u53D1\u5C55\u7A7A\u95F4\u3002</p></blockquote><h2 id="\u672A\u6765\u7684\u8BA1\u5212" tabindex="-1"><a class="header-anchor" href="#\u672A\u6765\u7684\u8BA1\u5212" aria-hidden="true">#</a> \u672A\u6765\u7684\u8BA1\u5212</h2><blockquote><p>\u8FD9\u91CC\u6536\u5F55\u4E86 <code>YukiReflection</code> \u53EF\u80FD\u4F1A\u5728\u540E\u671F\u6DFB\u52A0\u7684\u529F\u80FD\u3002</p></blockquote><h3 id="\u81EA\u52A8\u751F\u6210\u53CD\u5C04\u4EE3\u7801" tabindex="-1"><a class="header-anchor" href="#\u81EA\u52A8\u751F\u6210\u53CD\u5C04\u4EE3\u7801" aria-hidden="true">#</a> \u81EA\u52A8\u751F\u6210\u53CD\u5C04\u4EE3\u7801</h3><p>\u4F7F\u7528 <code>stub</code> \u7684\u65B9\u5F0F\u521B\u5EFA\u4E00\u4E2A <code>Kotlin</code> \u7C7B\uFF0C\u5E76\u58F0\u660E\u5176\u4E2D\u7684\u53C2\u6570\uFF0C\u4EE5\u53CA\u5176\u5728\u5404\u4E2A\u7248\u672C\u4E2D\u7684\u4E0D\u540C\u72B6\u6001\u3002</p><p>\u6BD4\u5982\u4E0B\u9762\u7684\u8FD9\u4E2A <code>Java</code> \u7C7B\u5C31\u662F\u6211\u4EEC\u9700\u8981\u53CD\u5C04\u7684\u76EE\u6807\u7C7B\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-java ext-java"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">package</span><span style="color:#ADBAC7;"> com.example.test;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">MyClass</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> String</span><span style="color:#F69D50;"> </span><span style="color:#ADBAC7;">myField</span><span style="color:#F69D50;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;test&quot;</span><span style="color:#ADBAC7;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">public</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">MyClass</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> String </span><span style="color:#DCBDFB;">myMethod1</span><span style="color:#ADBAC7;">(String </span><span style="color:#F69D50;">var1</span><span style="color:#ADBAC7;">, </span><span style="color:#F47067;">int</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">var2</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">myMethod2</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">private</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">void</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">myMethod3</span><span style="color:#ADBAC7;">(String </span><span style="color:#F69D50;">var1</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre></div><p>\u901A\u8FC7\u76EE\u524D API \u7684\u73B0\u6709\u7528\u6CD5\u53EF\u4EE5\u4F7F\u7528\u5982\u4E0B\u65B9\u5F0F\u53CD\u5C04\u8C03\u7528\u8FD9\u4E2A\u7C7B\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">classOf</span><span style="color:#F47067;">&lt;</span><span style="color:#F69D50;">MyClass</span><span style="color:#F47067;">&gt;</span><span style="color:#ADBAC7;">().buildOf().current {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u8C03\u7528 myField</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> value </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> field { name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;myField&quot;</span><span style="color:#ADBAC7;"> }.string()</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u8C03\u7528 myMethod1</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> methodValue </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> method { name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;myMethod1&quot;</span><span style="color:#ADBAC7;"> }.string(</span><span style="color:#96D0FF;">&quot;test&quot;</span><span style="color:#ADBAC7;">, </span><span style="color:#6CB6FF;">0</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u8C03\u7528 myMethod2</span></span>
<span class="line"><span style="color:#ADBAC7;">    method { name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;myMethod2&quot;</span><span style="color:#ADBAC7;"> }.call()</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u8C03\u7528 myMethod3</span></span>
<span class="line"><span style="color:#ADBAC7;">    method { name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;myMethod3&quot;</span><span style="color:#ADBAC7;"> }.call(</span><span style="color:#96D0FF;">&quot;test&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u76EE\u524D\u8981\u5B9E\u73B0\u7684\u529F\u80FD\u662F\u53EF\u4EE5\u4F7F\u7528\u53CD\u5C04\u529F\u80FD\u76F4\u63A5\u5B9A\u4E49\u4E3A\u5982\u4E0B <code>Kotlin</code> \u7C7B\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">package</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">com.example.test</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F47067;">@ReflectClass</span></span>
<span class="line"><span style="color:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">MyClass</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">@ReflectField</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> myField</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">String</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> fieldValueOf(</span><span style="color:#96D0FF;">&quot;none&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">@ReflectMethod</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">myMethod1</span><span style="color:#ADBAC7;">(var1</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">String</span><span style="color:#ADBAC7;">, var2</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">Int</span><span style="color:#ADBAC7;">)</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">String</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> methodReturnValueOf(</span><span style="color:#96D0FF;">&quot;none&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">@ReflectMethod</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">myMethod2</span><span style="color:#ADBAC7;">() </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">MethodReturnType</span><span style="color:#ADBAC7;">.</span><span style="color:#6CB6FF;">Unit</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">@ReflectMethod</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">myMethod3</span><span style="color:#ADBAC7;">(var1</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">String</span><span style="color:#ADBAC7;">) </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">MethodReturnType</span><span style="color:#ADBAC7;">.</span><span style="color:#6CB6FF;">Unit</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u7136\u540E\u6211\u4EEC\u5C31\u53EF\u4EE5\u76F4\u63A5\u8C03\u7528\u8FD9\u4E2A\u5B9A\u4E49\u597D\u7684 <code>Kotlin</code> \u7C7B\u6765\u5B9E\u73B0\u53CD\u5C04\u529F\u80FD\uFF0CAPI \u4F1A\u6839\u636E\u6CE8\u89E3\u81EA\u52A8\u751F\u6210\u53CD\u5C04\u4EE3\u7801\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F69D50;">MyClass</span><span style="color:#ADBAC7;">().</span><span style="color:#6CB6FF;">also</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u8C03\u7528 myField</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> value </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> it.myField</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u8C03\u7528 myMethod1</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> methodValue </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> it.myMethod1(</span><span style="color:#96D0FF;">&quot;test&quot;</span><span style="color:#ADBAC7;">, </span><span style="color:#6CB6FF;">0</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u8C03\u7528 myMethod2</span></span>
<span class="line"><span style="color:#ADBAC7;">    it.myMethod2()</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u8C03\u7528 myMethod3</span></span>
<span class="line"><span style="color:#ADBAC7;">    it.myMethod3(</span><span style="color:#96D0FF;">&quot;test&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u4EE5\u4E0A\u529F\u80FD\u53EF\u80FD\u4F1A\u5728\u5B9E\u9645\u63A8\u51FA\u540E\u6709\u6240\u53D8\u5316\uFF0C\u6700\u7EC8\u4EE5\u5B9E\u9645\u7248\u672C\u7684\u529F\u80FD\u4E3A\u51C6\u3002</p></div>`,19),e=[o];function c(t,r){return n(),a("div",null,e)}const y=s(p,[["render",c],["__file","future.html.vue"]]);export{y as default};
