import{_ as s,o as n,c as a,e as l}from"./app.87c2e303.js";const e={},o=l(`<h1 id="looking-for-future" tabindex="-1"><a class="header-anchor" href="#looking-for-future" aria-hidden="true">#</a> Looking for Future</h1><blockquote><p>The future is bright and uncertain, let us look forward to the future development space of <code>YukiReflection</code>.</p></blockquote><h2 id="future-plans" tabindex="-1"><a class="header-anchor" href="#future-plans" aria-hidden="true">#</a> Future Plans</h2><blockquote><p>Features that <code>YukiReflection</code> may add later are included here.</p></blockquote><h3 id="automatically-generate-reflection-code" tabindex="-1"><a class="header-anchor" href="#automatically-generate-reflection-code" aria-hidden="true">#</a> Automatically Generate Reflection Code</h3><p>Use <code>stub</code> to create a <code>Kotlin</code> class, and declare the parameters in it, as well as its different states in each version.</p><p>For example, the <code>Java</code> class below is the target class we need to reflect.</p><blockquote><p>The following example</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>Through the existing usage of the current API, this class can be called reflectively in the following way.</p><blockquote><p>The following example</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;">// Call 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;">// Call 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;">// Call 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;">// Call 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>The function to be implemented at present can be directly defined as the following <code>Kotlin</code> class using the reflection function.</p><blockquote><p>The following example</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>Then we can directly call this defined <code>Kotlin</code> class to implement the reflection function, and the API will automatically generate the reflection code according to the annotation.</p><blockquote><p>The following example</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;">// Call 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;">// Call 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;">// Call 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;">// Call 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">Tips</p><p>The above functions may change after the actual release, and the functions of the actual version shall prevail.</p></div>`,19),p=[o];function t(c,r){return n(),a("div",null,p)}const y=s(e,[["render",t],["__file","future.html.vue"]]);export{y as default};
