Initial commit
15
.gitignore
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
3
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
6
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
20
.idea/gradle.xml
generated
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/demo-app" />
|
||||
<option value="$PROJECT_DIR$/yukireflection" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
BIN
.idea/icon.png
generated
Normal file
After Width: | Height: | Size: 24 KiB |
11
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="FieldCanBeLocal" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
||||
<option name="processCode" value="true" />
|
||||
<option name="processLiterals" value="true" />
|
||||
<option name="processComments" value="true" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
10
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 HighCapable
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
80
README-zh-CN.md
Normal file
@@ -0,0 +1,80 @@
|
||||
# Yuki Reflection
|
||||
|
||||

|
||||

|
||||
[](https://t.me/YukiReflection)
|
||||
<br/><br/>
|
||||
<img src="https://github.com/fankes/YukiReflection/blob/master/img-src/icon.png?raw=true" width = "100" height = "100"/>
|
||||
<br/>
|
||||
<br/>
|
||||
🌴️ 一个使用 Kotlin 构建的 Android 平台高效反射 API。
|
||||
<br/>
|
||||
|
||||
[English](https://github.com/fankes/YukiReflection/blob/master/README.md) | 简体中文
|
||||
|
||||
## 这是什么
|
||||
|
||||
- 这是一个使用 Kotlin 基于 Java 原生反射 API 重新打造的一套简洁、高效的反射 API,同时也是 [YukiHookAPI](https://github.com/fankes/YukiHookAPI) 正在使用的核心功能
|
||||
- 名称取自 [《ももくり》女主 栗原 雪(Yuki)](https://www.bilibili.com/bangumi/play/ss5016)
|
||||
|
||||
## 它能做什么
|
||||
|
||||
- 取代 Java 原生的反射 API,使用更加人性化的语言实现一套更加完善的反射方案
|
||||
- 使用注解的方式声明需要反射的类或方法、变量,构造一个 `stub`,直接调用即可实现与反射 API 相同的功能,更加优雅高效 (正在开发,预计在后期逐渐实现此功能)
|
||||
|
||||
## 开始使用
|
||||
|
||||
- [点击这里](https://fankes.github.io/YukiReflection/zh-cn/) 前往文档页面查看更多详细教程和内容。
|
||||
|
||||
## 联系我们
|
||||
|
||||
- [点击加入 Telegram 群组](https://t.me/YukiReflection)
|
||||
|
||||
## 展望未来
|
||||
|
||||
如果你喜欢 `YukiReflection` 项目,欢迎为此项目贡献你的代码 **PR**,可以是任何改进的建议以及新增的功能。
|
||||
|
||||
## 合作项目
|
||||
|
||||
以下是经过合作并稳定使用 `YukiReflection` 的项目。
|
||||
|
||||
| Repository | Developer |
|
||||
|------------------------------------------------------|------------------------------------------|
|
||||
| [YukiHookAPI](https://github.com/fankes/YukiHookAPI) | [fankesyooni](https://github.com/fankes) |
|
||||
|
||||
你也在使用 `YukiReflection` 吗?快来 **PR** 将你的存储仓库添加到上方的列表 (私有仓库可以不需要注明网页链接)。
|
||||
|
||||
## 捐赠支持
|
||||
|
||||
- 工作不易,无意外情况此项目将继续维护下去,提供更多可能,欢迎打赏。<br/><br/>
|
||||
<img src="https://github.com/fankes/YukiReflection/blob/master/img-src/wechat_code.jpg?raw=true" width = "200" height = "200"/>
|
||||
|
||||
## 许可证
|
||||
|
||||
- [MIT](https://choosealicense.com/licenses/mit)
|
||||
|
||||
```
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2019-2023 HighCapable
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
版权所有 © 2019-2023 HighCapable
|
79
README.md
Normal file
@@ -0,0 +1,79 @@
|
||||
# Yuki Reflection
|
||||
|
||||

|
||||

|
||||
[](https://t.me/YukiReflection)
|
||||
<br/><br/>
|
||||
<img src="https://github.com/fankes/YukiReflection/blob/master/img-src/icon.png?raw=true" width = "100" height = "100"/>
|
||||
<br/>
|
||||
<br/>
|
||||
🌴️ An efficient Reflection API for the Android platform built in Kotlin.
|
||||
<br/>
|
||||
|
||||
English | [简体中文](https://github.com/fankes/YukiReflection/blob/master/README-zh-CN.md)
|
||||
|
||||
## What's this
|
||||
|
||||
- This is a concise and efficient Reflection API rebuilt based on Java's native Reflection API using Kotlin, and it is also the core function
|
||||
being used by [YukiHookAPI](https://github.com/fankes/YukiHookAPI)
|
||||
- The name is taken from ["ももくり" heroine Yuki Kurihara](https://www.bilibili.com/bangumi/play/ss5016)
|
||||
|
||||
## What it can do
|
||||
|
||||
- Instead of Java's native Reflection API, use a more user-friendly language to implement a more complete set of reflection solutions
|
||||
- Use annotations to declare classes, methods, and fields that need reflection, construct a `stub`, and call directly to achieve the same
|
||||
function as the Reflection API, which is more elegant and efficient (under development, and it is expected to gradually implement this function
|
||||
later)
|
||||
|
||||
## Get Started
|
||||
|
||||
- [Click here](https://fankes.github.io/YukiReflection/en/) go to the documentation page for more detailed tutorials and content.
|
||||
|
||||
## Contacts
|
||||
|
||||
- [Follow us on Telegram](https://t.me/YukiReflection)
|
||||
|
||||
## Features
|
||||
|
||||
If you like the `YukiReflection` project, we welcome you to make a **PR** in this project, any suggestions for improvement and new features.
|
||||
|
||||
## Cooperations
|
||||
|
||||
The following are projects that have collaborated and are using `YukiReflection`.
|
||||
|
||||
| Repository | Developer |
|
||||
|------------------------------------------------------|------------------------------------------|
|
||||
| [YukiHookAPI](https://github.com/fankes/YukiHookAPI) | [fankesyooni](https://github.com/fankes) |
|
||||
|
||||
Are you also using `YukiReflection`? Come and **PR** to add your repository to the list above (private repositories do not need to indicate web
|
||||
links).
|
||||
|
||||
## License
|
||||
|
||||
- [MIT](https://choosealicense.com/licenses/mit)
|
||||
|
||||
```
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2019-2023 HighCapable
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
Copyright © 2019-2023 HighCapable
|
45
build.gradle
Normal file
@@ -0,0 +1,45 @@
|
||||
//file:noinspection unused
|
||||
plugins {
|
||||
id 'com.android.application' version '7.4.0' apply false
|
||||
id 'com.android.library' version '7.4.0' apply false
|
||||
id 'org.jetbrains.kotlin.android' version '1.7.22' apply false
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.7.22' apply false
|
||||
}
|
||||
|
||||
ext {
|
||||
devId = "0"
|
||||
devUser = "fankesyooni"
|
||||
userEmail = "qzmmcn@163.com"
|
||||
groupId = "com.highcapable.yukireflection"
|
||||
apiVersion = "1.0.0"
|
||||
repoName = "YukiReflection"
|
||||
repoDescription = "An efficient Reflection API for the Android platform built in Kotlin."
|
||||
licenceName = "MIT License"
|
||||
licenceUrl = "https://github.com/fankes/YukiReflection/blob/master/LICENSE"
|
||||
website = "https://github.com/fankes/YukiReflection"
|
||||
githubConnection = "scm:git:git://github.com/path/to/repo.git"
|
||||
githubDeveloperConnection = "scm:git:ssh://github.com/path/to/repo.git"
|
||||
githubUrl = "https://github.com/path/to/repo"
|
||||
ossName = "OSSRH"
|
||||
ossUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取授权文件内容 - 用于 Maven 的提交
|
||||
*
|
||||
* 若编译失败请将路径替换为自己的或置空
|
||||
* @param name
|
||||
* @return [String]
|
||||
*/
|
||||
static String getFileContent(String name) {
|
||||
String result = ""
|
||||
try {
|
||||
FileReader reader = new FileReader("/Users/fankes/Project/Android/Library/YukiReflection/.gradle/" + name)
|
||||
BufferedReader buff = new BufferedReader(reader)
|
||||
result = buff.readLine()
|
||||
buff.close()
|
||||
reader.close()
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
return result
|
||||
}
|
1
demo-app/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
55
demo-app/build.gradle
Normal file
@@ -0,0 +1,55 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.highcapable.yukireflection.demo_app'
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.highcapable.yukireflection.demo_app"
|
||||
minSdk 21
|
||||
targetSdk 33
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '11'
|
||||
freeCompilerArgs = [
|
||||
'-Xno-param-assertions',
|
||||
'-Xno-call-assertions',
|
||||
'-Xno-receiver-assertions'
|
||||
]
|
||||
}
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':yukireflection')
|
||||
implementation 'androidx.core:core-ktx:1.9.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.6.0'
|
||||
implementation 'com.google.android.material:material:1.7.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
}
|
21
demo-app/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
@@ -0,0 +1,24 @@
|
||||
package com.highcapable.yukireflection
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.highcapable.yukireflection", appContext.packageName)
|
||||
}
|
||||
}
|
23
demo-app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Default"
|
||||
tools:targetApi="31">
|
||||
|
||||
<activity
|
||||
android:name=".ui.MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
BIN
demo-app/src/main/ic_launcher-playstore.png
Normal file
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,21 @@
|
||||
package com.highcapable.yukireflection.demo_app.test;
|
||||
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
public class Main {
|
||||
|
||||
private static String staticContent = "I am static!";
|
||||
|
||||
private final String content;
|
||||
|
||||
public Main(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public static String getStaticContent() {
|
||||
return staticContent;
|
||||
}
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* YukiReflection - An efficient Reflection API for the Android platform built in Kotlin.
|
||||
* Copyright (C) 2019-2023 HighCapable
|
||||
* https://github.com/fankes/YukiReflection
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* This file is Created by fankes on 2023/1/21.
|
||||
*/
|
||||
@file:Suppress("SetTextI18n", "UsePropertyAccessSyntax")
|
||||
|
||||
package com.highcapable.yukireflection.demo_app.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.highcapable.yukireflection.demo_app.databinding.ActivityMainBinding
|
||||
import com.highcapable.yukireflection.demo_app.test.Main
|
||||
import com.highcapable.yukireflection.factory.*
|
||||
import com.highcapable.yukireflection.type.java.StringClass
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ActivityMainBinding.inflate(layoutInflater).apply {
|
||||
setContentView(root)
|
||||
testObjectDirectlyButton.setOnClickListener {
|
||||
tipText.text = Main("I am directly call of new object").getContent()
|
||||
}
|
||||
testObjectReflectionButton.setOnClickListener {
|
||||
tipText.text =
|
||||
classOf<Main>().buildOf("I am reflection call of new object") { param(StringClass) }
|
||||
?.current()
|
||||
?.method {
|
||||
name = "getContent"
|
||||
emptyParam()
|
||||
}?.string() ?: ""
|
||||
}
|
||||
testStaticDirectlyButton.setOnClickListener {
|
||||
tipText.text = Main.getStaticContent()
|
||||
}
|
||||
testStaticReflectionButton.setOnClickListener {
|
||||
tipText.text = classOf<Main>().method {
|
||||
name = "getStaticContent"
|
||||
modifiers { isStatic }
|
||||
}.get().string()
|
||||
}
|
||||
testModifyStaticReflectionButton.setOnClickListener {
|
||||
classOf<Main>().field {
|
||||
name = "staticContent"
|
||||
modifiers { isStatic }
|
||||
}.get().set("I am static! Modified by reflection")
|
||||
tipText.text = "Field is modified success"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
59
demo-app/src/main/res/layout/activity_main.xml
Normal file
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
tools:context=".ui.MainActivity"
|
||||
tools:ignore="HardcodedText">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:text="Using functions below to test"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tip_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="35dp"
|
||||
android:text="Waiting for your operation"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/test_object_directly_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:text="Create an Object and Call Directly" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/test_object_reflection_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:text="Create an Object and Call Reflection" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/test_static_directly_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:text="Get Static and Call Directly" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/test_static_reflection_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:text="Get Static and Call Reflection" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/test_modify_static_reflection_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Modified Static Field Using Reflection" />
|
||||
</LinearLayout>
|
5
demo-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
BIN
demo-app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
demo-app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
demo-app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
demo-app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
demo-app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
demo-app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
demo-app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
demo-app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
demo-app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
demo-app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
demo-app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
demo-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 8.5 KiB |
BIN
demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 12 KiB |
19
demo-app/src/main/res/values-night/themes.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.Default" parent="Theme.Material3.DayNight">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/yuki_theme_color</item>
|
||||
<item name="colorPrimaryVariant">@color/yuki_theme_color</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/yuki_accent_color</item>
|
||||
<item name="colorSecondaryVariant">@color/yuki_accent_color</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor">@color/yuki_dark_color</item>
|
||||
<item name="android:navigationBarColor">@android:color/background_dark</item>
|
||||
<item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="android:windowSplashScreenAnimatedIcon" tools:targetApi="s">@mipmap/ic_launcher</item>
|
||||
</style>
|
||||
</resources>
|
9
demo-app/src/main/res/values/colors.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="yuki_theme_color">#FF31A4FF</color>
|
||||
<color name="yuki_accent_color">#FF777777</color>
|
||||
<color name="yuki_light_color">#FFF0F5FF</color>
|
||||
<color name="yuki_dark_color">#FF2D2726</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
4
demo-app/src/main/res/values/ic_launcher_background.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#31A4FF</color>
|
||||
</resources>
|
3
demo-app/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">YukiReflection</string>
|
||||
</resources>
|
19
demo-app/src/main/res/values/themes.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.Default" parent="Theme.Material3.DayNight">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/yuki_theme_color</item>
|
||||
<item name="colorPrimaryVariant">@color/yuki_theme_color</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/yuki_accent_color</item>
|
||||
<item name="colorSecondaryVariant">@color/yuki_accent_color</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor">@color/yuki_light_color</item>
|
||||
<item name="android:navigationBarColor">@android:color/background_light</item>
|
||||
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="android:windowSplashScreenAnimatedIcon" tools:targetApi="s">@mipmap/ic_launcher</item>
|
||||
</style>
|
||||
</resources>
|
@@ -0,0 +1,17 @@
|
||||
package com.highcapable.yukireflection
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
3
docs-source/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
src/.vuepress/.cache
|
||||
src/.vuepress/.temp
|
0
docs-source/.nojekyll
Normal file
3
docs-source/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"git.ignoreLimitWarning": true
|
||||
}
|
15
docs-source/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "yukireflection_docs",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@mr-hope/vuepress-plugin-copy-code": "^1.30.0",
|
||||
"@vuepress/plugin-prismjs": "^2.0.0-beta.51",
|
||||
"@vuepress/plugin-search": "^2.0.0-beta.51",
|
||||
"@vuepress/plugin-shiki": "^2.0.0-beta.51",
|
||||
"vuepress": "^2.0.0-beta.51"
|
||||
},
|
||||
"scripts": {
|
||||
"docs:dev": "vuepress dev src",
|
||||
"docs:build": "vuepress build src"
|
||||
}
|
||||
}
|
60
docs-source/src/.vuepress/config.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { defaultTheme } from 'vuepress';
|
||||
import { shikiPlugin } from '@vuepress/plugin-shiki';
|
||||
import { searchPlugin } from '@vuepress/plugin-search';
|
||||
import { navBarItems, sideBarItems, configs } from './configs/template';
|
||||
|
||||
export default {
|
||||
dest: configs.dev.dest,
|
||||
port: configs.dev.port,
|
||||
base: configs.website.base,
|
||||
head: [['link', { rel: 'icon', href: configs.website.icon }]],
|
||||
title: configs.website.title,
|
||||
description: configs.website.locales['/en/'].description,
|
||||
locales: configs.website.locales,
|
||||
theme: defaultTheme({
|
||||
logo: configs.website.logo,
|
||||
repo: configs.github.repo,
|
||||
docsRepo: configs.github.repo,
|
||||
docsBranch: configs.github.branch,
|
||||
docsDir: configs.github.dir,
|
||||
editLinkPattern: ':repo/edit/:branch/:path',
|
||||
sidebar: sideBarItems,
|
||||
sidebarDepth: 2,
|
||||
locales: {
|
||||
'/en/': {
|
||||
navbar: navBarItems['/en/'],
|
||||
selectLanguageText: 'English (US)',
|
||||
selectLanguageName: 'English',
|
||||
editLinkText: 'Edit this page on Github',
|
||||
tip: 'Tips',
|
||||
warning: 'Notice',
|
||||
danger: 'Pay Attention',
|
||||
},
|
||||
'/zh-cn/': {
|
||||
navbar: navBarItems['/zh-cn/'],
|
||||
selectLanguageText: '简体中文 (CN)',
|
||||
selectLanguageName: '简体中文',
|
||||
editLinkText: '在 Github 上编辑此页',
|
||||
notFound: ['这里什么都没有', '我们怎么到这来了?', '这是一个 404 页面', '看起来我们进入了错误的链接'],
|
||||
backToHome: '回到首页',
|
||||
contributorsText: '贡献者',
|
||||
lastUpdatedText: '上次更新',
|
||||
tip: '小提示',
|
||||
warning: '注意',
|
||||
danger: '特别注意',
|
||||
openInNewWindow: '在新窗口中打开',
|
||||
toggleColorMode: '切换颜色模式'
|
||||
}
|
||||
},
|
||||
}),
|
||||
plugins: [
|
||||
shikiPlugin({ theme: 'github-dark-dimmed' }),
|
||||
searchPlugin({
|
||||
isSearchable: (page) => page.path !== '/',
|
||||
locales: {
|
||||
'/en/': { placeholder: 'Search' },
|
||||
'/zh-cn/': { placeholder: '搜索' }
|
||||
}
|
||||
})
|
||||
]
|
||||
};
|
201
docs-source/src/.vuepress/configs/template.ts
Normal file
@@ -0,0 +1,201 @@
|
||||
import { i18n } from './utils';
|
||||
|
||||
const baseApiPath = '/api/public/com/highcapable/yukireflection/';
|
||||
|
||||
const navigationLinks = {
|
||||
start: [
|
||||
'/guide/home',
|
||||
'/guide/quick-start'
|
||||
],
|
||||
config: [
|
||||
'/config/api-example',
|
||||
'/config/api-exception'
|
||||
],
|
||||
apiDocs: [
|
||||
'/api/home',
|
||||
'/api/public/',
|
||||
'/api/features'
|
||||
],
|
||||
publicApi: [
|
||||
baseApiPath + 'YukiReflection',
|
||||
baseApiPath + 'type/android/ComponentTypeFactory',
|
||||
baseApiPath + 'type/android/GraphicsTypeFactory',
|
||||
baseApiPath + 'type/android/ViewTypeFactory',
|
||||
baseApiPath + 'type/java/VariableTypeFactory',
|
||||
baseApiPath + 'type/defined/DefinedTypeFactory',
|
||||
baseApiPath + 'factory/ReflectionFactory',
|
||||
baseApiPath + 'finder/members/MethodFinder',
|
||||
baseApiPath + 'finder/members/ConstructorFinder',
|
||||
baseApiPath + 'finder/members/FieldFinder',
|
||||
baseApiPath + 'finder/classes/DexClassFinder',
|
||||
baseApiPath + 'finder/classes/rules/result/MemberRulesResult',
|
||||
baseApiPath + 'finder/classes/rules/MemberRules',
|
||||
baseApiPath + 'finder/classes/rules/FieldRules',
|
||||
baseApiPath + 'finder/classes/rules/MethodRules',
|
||||
baseApiPath + 'finder/classes/rules/ConstructorRules',
|
||||
baseApiPath + 'finder/base/BaseFinder',
|
||||
baseApiPath + 'finder/base/rules/CountRules',
|
||||
baseApiPath + 'finder/base/rules/ModifierRules',
|
||||
baseApiPath + 'finder/base/rules/NameRules',
|
||||
baseApiPath + 'finder/base/rules/ObjectRules',
|
||||
baseApiPath + 'bean/VariousClass',
|
||||
baseApiPath + 'bean/CurrentClass',
|
||||
baseApiPath + 'bean/GenericClass'
|
||||
],
|
||||
about: [
|
||||
'/about/changelog',
|
||||
'/about/future',
|
||||
'/about/contacts',
|
||||
'/about/about'
|
||||
]
|
||||
};
|
||||
|
||||
export const configs = {
|
||||
dev: {
|
||||
dest: '../docs/',
|
||||
port: 9000
|
||||
},
|
||||
website: {
|
||||
base: '/YukiReflection/',
|
||||
icon: '/YukiReflection/images/logo.png',
|
||||
logo: '/images/logo.png',
|
||||
title: 'Yuki Reflection',
|
||||
locales: {
|
||||
'/en/': {
|
||||
lang: 'en-US',
|
||||
description: 'An efficient Reflection API for the Android platform built in Kotlin'
|
||||
},
|
||||
'/zh-cn/': {
|
||||
lang: 'zh-CN',
|
||||
description: '一个使用 Kotlin 构建的 Android 平台高效反射 API'
|
||||
}
|
||||
}
|
||||
},
|
||||
github: {
|
||||
repo: 'https://github.com/fankes/YukiReflection',
|
||||
branch: 'master',
|
||||
dir: 'docs-source/src'
|
||||
}
|
||||
};
|
||||
|
||||
export const navBarItems = {
|
||||
'/en/': [{
|
||||
text: 'Navigation',
|
||||
children: [{
|
||||
text: 'Get Started',
|
||||
children: [
|
||||
{ text: 'Introduce', link: i18n.string(navigationLinks.start[0], 'en') },
|
||||
{ text: 'Quick Start', link: i18n.string(navigationLinks.start[1], 'en') }
|
||||
]
|
||||
}, {
|
||||
text: 'Configs',
|
||||
children: [
|
||||
{ text: 'API Basic Configs', link: i18n.string(navigationLinks.config[0], 'en') },
|
||||
{ text: 'API Exception Handling', link: i18n.string(navigationLinks.config[1], 'en') }
|
||||
]
|
||||
}, {
|
||||
text: 'API Document',
|
||||
children: [{ text: 'Document Introduction', link: i18n.string(navigationLinks.apiDocs[0], 'en') }, {
|
||||
text: 'Public API',
|
||||
link: i18n.string(navigationLinks.publicApi[0], 'en'),
|
||||
activeMatch: i18n.string(navigationLinks.apiDocs[1], 'en')
|
||||
}, {
|
||||
text: 'Features',
|
||||
link: i18n.string(navigationLinks.apiDocs[2], 'en')
|
||||
}]
|
||||
}, {
|
||||
text: 'About',
|
||||
children: [
|
||||
{ text: 'Changelog', link: i18n.string(navigationLinks.about[0], 'en') },
|
||||
{ text: 'Looking for Future', link: i18n.string(navigationLinks.about[1], 'en') },
|
||||
{ text: 'Contact Us', link: i18n.string(navigationLinks.about[2], 'en') },
|
||||
{ text: 'About this Document', link: i18n.string(navigationLinks.about[3], 'en') }
|
||||
]
|
||||
}]
|
||||
}, {
|
||||
text: 'Contact Us',
|
||||
link: i18n.string(navigationLinks.about[2], 'en')
|
||||
}],
|
||||
'/zh-cn/': [{
|
||||
text: '导航',
|
||||
children: [{
|
||||
text: '入门',
|
||||
children: [
|
||||
{ text: '介绍', link: i18n.string(navigationLinks.start[0], 'zh-cn') },
|
||||
{ text: '快速开始', link: i18n.string(navigationLinks.start[1], 'zh-cn') }
|
||||
]
|
||||
}, {
|
||||
text: '配置',
|
||||
children: [
|
||||
{ text: 'API 基本配置', link: i18n.string(navigationLinks.config[0], 'zh-cn') },
|
||||
{ text: 'API 异常处理', link: i18n.string(navigationLinks.config[1], 'zh-cn') }
|
||||
]
|
||||
}, {
|
||||
text: 'API 文档',
|
||||
children: [{ text: '文档介绍', link: i18n.string(navigationLinks.apiDocs[0], 'zh-cn') }, {
|
||||
text: 'Public API',
|
||||
link: i18n.string(navigationLinks.publicApi[0], 'zh-cn'),
|
||||
activeMatch: i18n.string(navigationLinks.apiDocs[1], 'zh-cn')
|
||||
}, {
|
||||
text: '功能介绍',
|
||||
link: i18n.string(navigationLinks.apiDocs[2], 'zh-cn')
|
||||
}]
|
||||
}, {
|
||||
text: '关于',
|
||||
children: [
|
||||
{ text: '更新日志', link: i18n.string(navigationLinks.about[0], 'zh-cn') },
|
||||
{ text: '展望未来', link: i18n.string(navigationLinks.about[1], 'zh-cn') },
|
||||
{ text: '联系我们', link: i18n.string(navigationLinks.about[2], 'zh-cn') },
|
||||
{ text: '关于此文档', link: i18n.string(navigationLinks.about[3], 'zh-cn') }
|
||||
]
|
||||
}]
|
||||
}, {
|
||||
text: '联系我们',
|
||||
link: i18n.string(navigationLinks.about[2], 'zh-cn')
|
||||
}]
|
||||
};
|
||||
|
||||
export const sideBarItems = {
|
||||
'/en/': [{
|
||||
text: 'Get Started',
|
||||
collapsible: true,
|
||||
children: i18n.array(navigationLinks.start, 'en')
|
||||
}, {
|
||||
text: 'Configs',
|
||||
collapsible: true,
|
||||
children: i18n.array(navigationLinks.config, 'en')
|
||||
}, {
|
||||
text: 'API Document',
|
||||
collapsible: true,
|
||||
children: [i18n.string(navigationLinks.apiDocs[0], 'en'), {
|
||||
text: 'Public API' + i18n.space,
|
||||
collapsible: true,
|
||||
children: i18n.array(navigationLinks.publicApi, 'en')
|
||||
}, i18n.string(navigationLinks.apiDocs[2], 'en')]
|
||||
}, {
|
||||
text: 'About',
|
||||
collapsible: true,
|
||||
children: i18n.array(navigationLinks.about, 'en')
|
||||
}],
|
||||
'/zh-cn/': [{
|
||||
text: '入门',
|
||||
collapsible: true,
|
||||
children: i18n.array(navigationLinks.start, 'zh-cn')
|
||||
}, {
|
||||
text: '配置',
|
||||
collapsible: true,
|
||||
children: i18n.array(navigationLinks.config, 'zh-cn')
|
||||
}, {
|
||||
text: 'API 文档',
|
||||
collapsible: true,
|
||||
children: [i18n.string(navigationLinks.apiDocs[0], 'zh-cn'), {
|
||||
text: 'Public API' + i18n.space,
|
||||
collapsible: true,
|
||||
children: i18n.array(navigationLinks.publicApi, 'zh-cn')
|
||||
}, i18n.string(navigationLinks.apiDocs[2], 'zh-cn')]
|
||||
}, {
|
||||
text: '关于',
|
||||
collapsible: true,
|
||||
children: i18n.array(navigationLinks.about, 'zh-cn')
|
||||
}]
|
||||
};
|
13
docs-source/src/.vuepress/configs/utils.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export const i18n = {
|
||||
space: ' ',
|
||||
string: (content: string, locale: string) => {
|
||||
return '/' + locale + content;
|
||||
},
|
||||
array: (contents: string[], locale: string) => {
|
||||
const newContents: string[] = [];
|
||||
contents.forEach((content) => {
|
||||
newContents.push(i18n.string(content, locale));
|
||||
});
|
||||
return newContents;
|
||||
}
|
||||
};
|
BIN
docs-source/src/.vuepress/public/images/logo.png
Normal file
After Width: | Height: | Size: 24 KiB |
179
docs-source/src/.vuepress/styles/index.scss
Normal file
@@ -0,0 +1,179 @@
|
||||
$primary-color: rgb(49, 164, 255);
|
||||
$accent-color: rgb(129, 189, 249);
|
||||
$content-width: 965px;
|
||||
$scroll-bar-width: 8px;
|
||||
$scroll-bar-height: 6.5px;
|
||||
$scroll-bar-border-radius: 50px;
|
||||
$scroll-bar-track-color-code: rgb(86, 96, 110);
|
||||
$scroll-bar-thumb-hover-color-code: rgb(121, 135, 155);
|
||||
|
||||
:root {
|
||||
--c-brand: #{$primary-color};
|
||||
--c-brand-light: #{$accent-color};
|
||||
--content-width: #{$content-width};
|
||||
}
|
||||
|
||||
code {
|
||||
padding: 3px 5px 3px 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.badge {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.custom-container {
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.sidebar-item {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.language-text {
|
||||
::-webkit-scrollbar-track {
|
||||
background: #{$scroll-bar-track-color-code};
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #{$scroll-bar-thumb-hover-color-code};
|
||||
}
|
||||
}
|
||||
|
||||
.language-kotlin {
|
||||
::-webkit-scrollbar-track {
|
||||
background: #{$scroll-bar-track-color-code};
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #{$scroll-bar-thumb-hover-color-code};
|
||||
}
|
||||
}
|
||||
|
||||
.language-java {
|
||||
::-webkit-scrollbar-track {
|
||||
background: #{$scroll-bar-track-color-code};
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #{$scroll-bar-thumb-hover-color-code};
|
||||
}
|
||||
}
|
||||
|
||||
.language-groovy {
|
||||
::-webkit-scrollbar-track {
|
||||
background: #{$scroll-bar-track-color-code};
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #{$scroll-bar-thumb-hover-color-code};
|
||||
}
|
||||
}
|
||||
|
||||
.language-xml {
|
||||
::-webkit-scrollbar-track {
|
||||
background: #{$scroll-bar-track-color-code};
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #{$scroll-bar-thumb-hover-color-code};
|
||||
}
|
||||
}
|
||||
|
||||
.hidden-anchor-page {
|
||||
h6 {
|
||||
color: transparent;
|
||||
margin-bottom: -35px;
|
||||
padding-top: 50px;
|
||||
}
|
||||
}
|
||||
|
||||
.code-page {
|
||||
h1 {
|
||||
font-size: 24pt;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 18pt;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 15pt;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 9.6pt;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 8.4pt;
|
||||
}
|
||||
|
||||
.symbol {
|
||||
color: rgb(142, 155, 168);
|
||||
}
|
||||
|
||||
.deprecated {
|
||||
color: rgb(142, 155, 168);
|
||||
text-decoration: line-through;
|
||||
}
|
||||
}
|
||||
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: #{$scroll-bar-width};
|
||||
height: #{$scroll-bar-height};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: rgb(234, 236, 239);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgb(189, 189, 189);
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: rgb(133, 133, 133);
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
}
|
||||
|
||||
html.dark {
|
||||
--c-brand: #{$primary-color};
|
||||
--c-brand-light: #{$accent-color};
|
||||
--content-width: #{$content-width};
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: #{$scroll-bar-width};
|
||||
height: #{$scroll-bar-height};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: rgb(41, 46, 53);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgb(65, 72, 83);
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: rgb(56, 62, 72);
|
||||
border-radius: #{$scroll-bar-border-radius};
|
||||
}
|
||||
}
|
33
docs-source/src/en/about/about.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# About this Document
|
||||
|
||||
> This document is powered by [VuePress](https://v2.vuepress.vuejs.org/en).
|
||||
|
||||
## License
|
||||
|
||||
[The MIT License (MIT)](https://github.com/fankes/YukiReflection/blob/master/LICENSE)
|
||||
|
||||
```:no-line-numbers
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2019-2023 HighCapable
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
Copyright © 2019-2023 HighCapable
|
21
docs-source/src/en/about/changelog.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Changelog
|
||||
|
||||
> The version update history of `YukiReflection` is recorded here.
|
||||
|
||||
::: danger
|
||||
|
||||
We will only maintain the latest API version, if you are using an outdate API version, you voluntarily renounce any possibility of maintenance.
|
||||
|
||||
:::
|
||||
|
||||
::: warning
|
||||
|
||||
To avoid translation time consumption, Changelog will use **Google Translation** from **Chinese** to **English**, please refer to the original text for actual reference.
|
||||
|
||||
Time zone of version release date: **UTC+8**
|
||||
|
||||
:::
|
||||
|
||||
### 1.0.0 | 2023.01.26  <Badge type="tip" text="latest" vertical="middle" />
|
||||
|
||||
- The first version is submitted to Maven
|
13
docs-source/src/en/about/contacts.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Contact Us
|
||||
|
||||
> If you have any questions in use, or have any constructive suggestions, you can contact us.
|
||||
|
||||
Join us [Click to join Telegram group](https://t.me/YukiReflection)
|
||||
|
||||
Find me on **Twitter** [@fankesyooni](https://twitter.com/fankesyooni)
|
||||
|
||||
## Help with Maintenance
|
||||
|
||||
Thank you for choosing and using `YukiReflection`.
|
||||
|
||||
If you have code-related suggestions and requests, you can submit a Pull Request on Github.
|
104
docs-source/src/en/about/future.md
Normal file
@@ -0,0 +1,104 @@
|
||||
# Looking for Future
|
||||
|
||||
> The future is bright and uncertain, let us look forward to the future development space of `YukiReflection`.
|
||||
|
||||
## Future Plans
|
||||
|
||||
> Features that `YukiReflection` may add later are included here.
|
||||
|
||||
### Automatically Generate Reflection Code
|
||||
|
||||
Use `stub` to create a `Kotlin` class, and declare the parameters in it, as well as its different states in each version.
|
||||
|
||||
For example, the `Java` class below is the target class we need to reflect.
|
||||
|
||||
> The following example
|
||||
|
||||
```java:no-line-numbers
|
||||
package com.example.test;
|
||||
|
||||
public class MyClass {
|
||||
|
||||
private String myField = "test";
|
||||
|
||||
public MyClass() {
|
||||
//...
|
||||
}
|
||||
|
||||
private String myMethod1(String var1, int var2) {
|
||||
//...
|
||||
}
|
||||
|
||||
private void myMethod2() {
|
||||
//...
|
||||
}
|
||||
|
||||
private void myMethod3(String var1) {
|
||||
//...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Through the existing usage of the current API, this class can be called reflectively in the following way.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
classOf<MyClass>().buildOf().current {
|
||||
// Call myField
|
||||
val value = field { name = "myField" }.string()
|
||||
// Call myMethod1
|
||||
val methodValue = method { name = "myMethod1" }.string("test", 0)
|
||||
// Call myMethod2
|
||||
method { name = "myMethod2" }.call()
|
||||
// Call myMethod3
|
||||
method { name = "myMethod3" }.call("test")
|
||||
}
|
||||
```
|
||||
|
||||
The function to be implemented at present can be directly defined as the following `Kotlin` class using the reflection function.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
package com.example.test
|
||||
|
||||
@ReflectClass
|
||||
class MyClass {
|
||||
|
||||
@ReflectField
|
||||
val myField: String = fieldValueOf("none")
|
||||
|
||||
@ReflectMethod
|
||||
fun myMethod1(var1: String, var2: Int): String = methodReturnValueOf("none")
|
||||
|
||||
@ReflectMethod
|
||||
fun myMethod2() = MethodReturnType.Unit
|
||||
|
||||
@ReflectMethod
|
||||
fun myMethod3(var1: String) = MethodReturnType.Unit
|
||||
}
|
||||
```
|
||||
|
||||
Then we can directly call this defined `Kotlin` class to implement the reflection function, and the API will automatically generate the reflection code according to the annotation.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
MyClass().also {
|
||||
// Call myField
|
||||
val value = it.myField
|
||||
// Call myMethod1
|
||||
val methodValue = it.myMethod1("test", 0)
|
||||
// Call myMethod2
|
||||
it.myMethod2()
|
||||
// Call myMethod3
|
||||
it.myMethod3("test")
|
||||
}
|
||||
```
|
||||
|
||||
::: tip
|
||||
|
||||
The above functions may change after the actual release, and the functions of the actual version shall prevail.
|
||||
|
||||
:::
|
1757
docs-source/src/en/api/features.md
Normal file
55
docs-source/src/en/api/home.md
Normal file
@@ -0,0 +1,55 @@
|
||||
---
|
||||
next:
|
||||
text: Public API
|
||||
link: /en/api/public/com/highcapable/yukireflection/YukiReflection
|
||||
---
|
||||
|
||||
# Document Introduce
|
||||
|
||||
> The document here will synchronize the relevant usage of the latest API version, please keep `YukiReflection` as the latest version to use the latest version of the function.
|
||||
|
||||
## Function Description
|
||||
|
||||
> The function description mainly introduces the related usage and purpose of the current API.
|
||||
|
||||
## Function Example Description
|
||||
|
||||
> The function examples mainly show the basic usage examples of the current API for reference.
|
||||
|
||||
## Change Record Description
|
||||
|
||||
The function of the first version will be marked as `v<version>` `first`;
|
||||
|
||||
New function added later will be marked as `v<version>` `added`;
|
||||
|
||||
Later modified function will be appended as `v<version>` `modified`;
|
||||
|
||||
Later deprecated function will be marked as `v<version>` `deprecated` and strikethrough;
|
||||
|
||||
Later removed function will be marked as `v<version>` `removed` and strikethrough.
|
||||
|
||||
## Related Symbols Description
|
||||
|
||||
- *kt* Kotlin Static File
|
||||
|
||||
- *annotation* Annotation Class
|
||||
|
||||
- *interface* Interface Class
|
||||
|
||||
- *object* Class (Singleton)
|
||||
|
||||
- *class* Class
|
||||
|
||||
- *field* Field or `get` / `set` method or read-only `get` method
|
||||
|
||||
- *method* Method
|
||||
|
||||
- *enum* Enum constant
|
||||
|
||||
- *ext-field* Extension field (global)
|
||||
|
||||
- *ext-method* Extension method (global)
|
||||
|
||||
- *i-ext-field* Extension field (internal)
|
||||
|
||||
- *i-ext-method* Extension method (internal)
|
@@ -0,0 +1,163 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# YukiReflection <span class="symbol">- object</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
object YukiReflection
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 这是 `YukiReflection` 的装载调用类。
|
||||
|
||||
## API_VERSION_NAME <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
const val API_VERSION_NAME: String
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获取当前 `YukiReflection` 的版本。
|
||||
|
||||
## API_VERSION_CODE <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
const val API_VERSION_CODE: Int
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获取当前 `YukiReflection` 的版本号。
|
||||
|
||||
## Configs <span class="symbol">- object</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
object Configs
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 对 API 相关功能的配置类。
|
||||
|
||||
### debugTag <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var debugTag: String
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 这是一个调试日志的全局标识。
|
||||
|
||||
默认文案为 `YukiReflection`。
|
||||
|
||||
你可以修改为你自己的文案。
|
||||
|
||||
### isDebug <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var isDebug: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 是否启用 Debug 模式。
|
||||
|
||||
默认不启用,启用后将交由日志输出管理器打印详细日志 (例如反射查找功能的耗时) 到控制台。
|
||||
|
||||
请过滤 `debugTag` 即可找到每条日志。
|
||||
|
||||
### isAllowPrintingLogs <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var isAllowPrintingLogs: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 是否启用调试日志的输出功能。
|
||||
|
||||
::: warning
|
||||
|
||||
关闭后将会停用 **YukiReflection** 对全部日志的输出。
|
||||
|
||||
:::
|
||||
|
||||
### isEnableMemberCache <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var isEnableMemberCache: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 是否启用 `Member` 缓存功能。
|
||||
|
||||
为防止 `Member` 复用过高造成的系统 GC 问题,此功能默认启用。
|
||||
|
||||
启用后会缓存已经找到的 `Method`、`Constructor`、`Field`。
|
||||
|
||||
缓存的 `Member` 都将处于 `ReflectsCacheStore` 的全局静态实例中。
|
||||
|
||||
推荐使用 `MethodFinder`、`ConstructorFinder`、`FieldFinder` 来获取 `Member`。
|
||||
|
||||
除非缓存的 `Member` 发生了混淆的问题,例如使用 R8 混淆后的 APP 的目标 `Member`,否则建议启用。
|
||||
|
||||
## configs <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun configs(initiate: Configs.() -> Unit)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 对 `Configs` 类实现了一个 `lambda` 方法体。
|
||||
|
||||
你可以轻松地调用它进行配置。
|
@@ -0,0 +1,229 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# CurrentClass <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class CurrentClass internal constructor(internal val classSet: Class<*>, internal val instance: Any)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 当前实例的类操作对象。
|
||||
|
||||
## name <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val name: String
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得当前 `classSet` 的 `Class.getName`。
|
||||
|
||||
## simpleName <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val simpleName: String
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得当前 `classSet` 的 `Class.getSimpleName`。
|
||||
|
||||
## generic <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun generic(): GenericClass?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得当前实例中的泛型父类。
|
||||
|
||||
如果当前实例不存在泛型将返回 `null`。
|
||||
|
||||
## generic <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun generic(initiate: GenericClass.() -> Unit): GenericClass?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得当前实例中的泛型父类。
|
||||
|
||||
如果当前实例不存在泛型将返回 `null`。
|
||||
|
||||
## superClass <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun superClass(): SuperClass
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 调用父类实例。
|
||||
|
||||
## field <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun field(initiate: FieldConditions): FieldFinder.Result.Instance
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 调用当前实例中的变量。
|
||||
|
||||
## method <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun method(initiate: MethodConditions): MethodFinder.Result.Instance
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 调用当前实例中的方法。
|
||||
|
||||
## SuperClass <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class SuperClass internal constructor(internal val superClassSet: Class<*>)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 当前类的父类实例的类操作对象。
|
||||
|
||||
### name <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val name: String
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得当前 `classSet` 中父类的 `Class.getName`。
|
||||
|
||||
### simpleName <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val simpleName: String
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得当前 `classSet` 中父类的 `Class.getSimpleName`。
|
||||
|
||||
### generic <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun generic(): GenericClass?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得当前实例父类中的泛型父类。
|
||||
|
||||
如果当前实例不存在泛型将返回 `null`。
|
||||
|
||||
### generic <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun generic(initiate: GenericClass.() -> Unit): GenericClass?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得当前实例父类中的泛型父类。
|
||||
|
||||
如果当前实例不存在泛型将返回 `null`。
|
||||
|
||||
### field <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun field(initiate: FieldConditions): FieldFinder.Result.Instance
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 调用父类实例中的变量。
|
||||
|
||||
### method <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun method(initiate: MethodConditions): MethodFinder.Result.Instance
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 调用父类实例中的方法。
|
@@ -0,0 +1,43 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# GenericClass <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class GenericClass internal constructor(private val type: ParameterizedType)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 当前 `Class` 的泛型父类操作对象。
|
||||
|
||||
## argument <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun argument(index: Int): Class<*>
|
||||
```
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> argument(index: Int): Class<T>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得泛型参数数组下标的 `Class` 实例。
|
@@ -0,0 +1,59 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# VariousClass <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class VariousClass(private vararg val name: String)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 这是一个不确定性 `Class` 类名装载器,通过 `name` 装载 `Class` 名称数组。
|
||||
|
||||
## get <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun get(loader: ClassLoader? = null, initialize: Boolean): Class<*>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获取匹配的实体类。
|
||||
|
||||
使用当前 `loader` 装载目标 `Class`。
|
||||
|
||||
## getOrNull <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun getOrNull(loader: ClassLoader? = null, initialize: Boolean): Class<*>?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获取匹配的实体类。
|
||||
|
||||
使用当前 `loader` 装载目标 `Class`。
|
||||
|
||||
匹配不到 `Class` 会返回 `null`,不会抛出异常。
|
@@ -0,0 +1,638 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# ReflectionFactory <span class="symbol">- kt</span>
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 这是自定义 `Member` 和 `Class` 相关功能的查找匹配以及 `invoke` 的封装类。
|
||||
|
||||
## ClassLoader.listOfClasses <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun ClassLoader.listOfClasses(): List<String>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 写出当前 `ClassLoader` 下所有 `Class` 名称数组。
|
||||
|
||||
::: warning
|
||||
|
||||
此方法在 **Class** 数量过多时会非常耗时。
|
||||
|
||||
若要按指定规则查找一个 **Class**,请使用 [ClassLoader.searchClass](#classloader-searchclass-ext-method) 方法。
|
||||
|
||||
:::
|
||||
|
||||
## ClassLoader.searchClass <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun ClassLoader.searchClass(context: Context?, name: String, async: Boolean, initiate: ClassConditions): DexClassFinder.Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 通过当前 `ClassLoader` 按指定条件查找并得到 **Dex** 中的 `Class`。
|
||||
|
||||
::: danger
|
||||
|
||||
此方法在 **Class** 数量过多及查找条件复杂时会非常耗时。
|
||||
|
||||
建议启用 **async** 或设置 **name** 参数,**name** 参数将在当前 APP 不同版本中自动进行本地缓存以提升效率。
|
||||
|
||||
如果使用了 **async** 或 **name** 参数,则必须填写 **context** 参数。
|
||||
|
||||
此功能尚在试验阶段,性能与稳定性可能仍然存在问题,使用过程遇到问题请向我们报告并帮助我们改进。
|
||||
|
||||
:::
|
||||
|
||||
## Class.hasExtends <span class="symbol">- ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val Class<*>.hasExtends: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 当前 `Class` 是否有继承关系,父类是 `Any` 将被认为没有继承关系。
|
||||
|
||||
## Class?.extends <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
infix fun Class<*>?.extends(other: Class<*>?): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 当前 `Class` 是否继承于 `other`。
|
||||
|
||||
如果当前 `Class` 就是 `other` 也会返回 `true`。
|
||||
|
||||
如果当前 `Class` 为 `null` 或 `other` 为 `null` 会返回 `false`。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以使用此方法来判断两个 `Class` 是否存在继承关系。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// 假设下面这两个 Class 就是你需要判断的 Class
|
||||
val classA: Class<*>?
|
||||
val classB: Class<*>?
|
||||
// 判断 A 是否继承于 B
|
||||
if (classA extends classB) {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
## Class?.notExtends <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
infix fun Class<*>?.notExtends(other: Class<*>?): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 当前 `Class` 是否不继承于 `other`。
|
||||
|
||||
此方法相当于 `extends` 的反向判断。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以使用此方法来判断两个 `Class` 是否不存在继承关系。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// 假设下面这两个 Class 就是你需要判断的 Class
|
||||
val classA: Class<*>?
|
||||
val classB: Class<*>?
|
||||
// 判断 A 是否不继承于 B
|
||||
if (classA notExtends classB) {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
## Class?.implements <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
infix fun Class<*>?.implements(other: Class<*>?): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 当前 `Class` 是否实现了 `other` 接口类。
|
||||
|
||||
如果当前 `Class` 为 `null` 或 `other` 为 `null` 会返回 `false`。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以使用此方法来判断两个 `Class` 是否存在依赖关系。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// 假设下面这两个 Class 就是你需要判断的 Class
|
||||
val classA: Class<*>?
|
||||
val classB: Class<*>?
|
||||
// 判断 A 是否实现了 B 接口类
|
||||
if (classA implements classB) {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
## Class?.notImplements <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
infix fun Class<*>?.notImplements(other: Class<*>?): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 当前 `Class` 是否未实现 `other` 接口类。
|
||||
|
||||
此方法相当于 `implements` 的反向判断。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以使用此方法来判断两个 `Class` 是否不存在依赖关系。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// 假设下面这两个 Class 就是你需要判断的 Class
|
||||
val classA: Class<*>?
|
||||
val classB: Class<*>?
|
||||
// 判断 A 是否未实现 B 接口类
|
||||
if (classA notImplements classB) {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
## Class.toJavaPrimitiveType <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun Class<*>.toJavaPrimitiveType(): Class<*>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 自动转换当前 `Class` 为 Java 原始类型 (Primitive Type)。
|
||||
|
||||
如果当前 `Class` 为 Java 或 Kotlin 基本类型将自动执行类型转换。
|
||||
|
||||
当前能够自动转换的基本类型如下。
|
||||
|
||||
- `kotlin.Unit`
|
||||
- `java.lang.Void`
|
||||
- `java.lang.Boolean`
|
||||
- `java.lang.Integer`
|
||||
- `java.lang.Float`
|
||||
- `java.lang.Double`
|
||||
- `java.lang.Long`
|
||||
- `java.lang.Short`
|
||||
- `java.lang.Character`
|
||||
- `java.lang.Byte`
|
||||
|
||||
## String.toClass <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.toClass(loader: ClassLoader?, initialize: Boolean): Class<*>
|
||||
```
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> String.toClass(loader: ClassLoader?, initialize: Boolean): Class<T>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 通过字符串类名转换为 `loader` 中的实体类。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以直接填写你要查找的目标 `Class`,必须在默认 `ClassLoader` 下存在。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
"com.example.demo.DemoClass".toClass()
|
||||
```
|
||||
|
||||
你还可以自定义 `Class` 所在的 `ClassLoader`。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
val customClassLoader: ClassLoader? = ... // 假设这个就是你的 ClassLoader
|
||||
"com.example.demo.DemoClass".toClass(customClassLoader)
|
||||
```
|
||||
|
||||
你还可以指定 `Class` 的目标类型。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// 指定的 DemoClass 必须存在或为可访问的 stub
|
||||
"com.example.demo.DemoClass".toClass<DemoClass>()
|
||||
```
|
||||
|
||||
你还可以设置在获取到这个 `Class` 时是否自动执行其默认的静态方法块,默认情况下不会执行。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// 获取并执行 DemoClass 默认的静态方法块
|
||||
"com.example.demo.DemoClass".toClass(initialize = true)
|
||||
```
|
||||
|
||||
默认的静态方法块在 Java 中使用如下方式定义。
|
||||
|
||||
> The following example
|
||||
|
||||
```java:no-line-numbers
|
||||
public class DemoClass {
|
||||
|
||||
static {
|
||||
// 这里是静态方法块的内容
|
||||
}
|
||||
|
||||
public DemoClass() {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## String.toClassOrNull <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.toClassOrNull(loader: ClassLoader?, initialize: Boolean): Class<*>?
|
||||
```
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> String.toClassOrNull(loader: ClassLoader?, initialize: Boolean): Class<T>?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 通过字符串类名转换为 `loader` 中的实体类。
|
||||
|
||||
找不到 `Class` 会返回 `null`,不会抛出异常。
|
||||
|
||||
**Function Example**
|
||||
|
||||
用法请参考 [String.toClass](#string-toclass-ext-method) 方法。
|
||||
|
||||
## classOf <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> classOf(loader: ClassLoader?, initialize: Boolean): Class<T>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 通过 `T` 得到其 `Class` 实例并转换为实体类。
|
||||
|
||||
**Function Example**
|
||||
|
||||
我们要获取一个 `Class` 在 `Kotlin` 下不通过反射时应该这样做。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
DemoClass::class.java
|
||||
```
|
||||
|
||||
现在,你可以直接 `cast` 一个实例并获取它的 `Class` 对象,必须在当前 `ClassLoader` 下存在。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
classOf<DemoClass>()
|
||||
```
|
||||
|
||||
若目标存在的 `Class` 为 `stub`,通过这种方式,你还可以自定义 `Class` 所在的 `ClassLoader`。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
val customClassLoader: ClassLoader? = ... // 假设这个就是你的 ClassLoader
|
||||
classOf<DemoClass>(customClassLoader)
|
||||
```
|
||||
|
||||
## String.hasClass <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.hasClass(loader: ClassLoader?): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 通过字符串类名使用指定的 `ClassLoader` 查找是否存在。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以轻松的使用此方法判断字符串中的类是否存在,效果等同于直接使用 `Class.forName`。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
if("com.example.demo.DemoClass".hasClass()) {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
填入方法中的 `loader` 参数可判断指定的 `ClassLoader` 中的 `Class` 是否存在。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
val customClassLoader: ClassLoader? = ... // 假设这个就是你的 ClassLoader
|
||||
if("com.example.demo.DemoClass".hasClass(customClassLoader)) {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
## Class.hasField <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.hasField(initiate: FieldConditions): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 查找变量是否存在。
|
||||
|
||||
## Class.hasMethod <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.hasMethod(initiate: MethodConditions): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 查找方法是否存在。
|
||||
|
||||
## Class.hasConstructor <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.hasConstructor(initiate: ConstructorConditions): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 查找构造方法是否存在。
|
||||
|
||||
## Member.hasModifiers <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Member.hasModifiers(conditions: ModifierConditions): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 查找 `Member` 中匹配的描述符。
|
||||
|
||||
## Class.hasModifiers <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.hasModifiers(conditions: ModifierConditions): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 查找 `Class` 中匹配的描述符。
|
||||
|
||||
## Class.field <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.field(initiate: FieldConditions): FieldFinder.Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 查找并得到变量。
|
||||
|
||||
## Class.method <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.method(initiate: MethodConditions): MethodFinder.Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 查找并得到方法。
|
||||
|
||||
## Class.constructor <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.constructor(initiate: ConstructorConditions): ConstructorFinder.Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 查找并得到构造方法。
|
||||
|
||||
## Class.generic <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun Class<*>.generic(): GenericClass?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得当前 `Class` 的泛型父类。
|
||||
|
||||
如果当前实例不存在泛型将返回 `null`。
|
||||
|
||||
## Class.generic <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.generic(initiate: GenericClass.() -> Unit): GenericClass?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得当前 `Class` 的泛型父类。
|
||||
|
||||
如果当前实例不存在泛型将返回 `null`。
|
||||
|
||||
## Any.current <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T : Any> T.current(ignored: Boolean): CurrentClass
|
||||
```
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T : Any> T.current(ignored: Boolean, initiate: CurrentClass.() -> Unit): T
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得当前实例的类操作对象。
|
||||
|
||||
## Class.buildOf <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.buildOf(vararg args: Any?, initiate: ConstructorConditions): Any?
|
||||
```
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <T> Class<*>.buildOf(vararg args: Any?, initiate: ConstructorConditions): T?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 通过构造方法创建新实例,指定类型 `T` 或任意类型 `Any`。
|
||||
|
||||
## Class.allMethods <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.allMethods(isAccessible: Boolean, result: (index: Int, method: Method) -> Unit)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 遍历当前类中的所有方法。
|
||||
|
||||
## Class.allConstructors <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.allConstructors(isAccessible: Boolean, result: (index: Int, constructor: Constructor<*>) -> Unit)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 遍历当前类中的所有构造方法。
|
||||
|
||||
## Class.allFields <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.allFields(isAccessible: Boolean, result: (index: Int, field: Field) -> Unit)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 遍历当前类中的所有变量。
|
@@ -0,0 +1,127 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# BaseFinder <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
abstract class BaseFinder
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 这是 `Class` 与 `Member` 查找类功能的基本类实现。
|
||||
|
||||
## BaseFinder.IndexTypeCondition <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class IndexTypeCondition internal constructor(private val type: IndexConfigType)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 字节码下标筛选实现类。
|
||||
|
||||
### index <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun index(num: Int)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置下标。
|
||||
|
||||
若 `index` 小于零则为倒序,此时可以使用 `IndexTypeConditionSort.reverse` 方法实现。
|
||||
|
||||
可使用 `IndexTypeConditionSort.first` 和 `IndexTypeConditionSort.last` 设置首位和末位筛选条件。
|
||||
|
||||
### index <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun index(): IndexTypeConditionSort
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到下标。
|
||||
|
||||
### IndexTypeConditionSort <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class IndexTypeConditionSort internal constructor()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 字节码下标排序实现类。
|
||||
|
||||
#### first <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun first()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置满足条件的第一个。
|
||||
|
||||
#### last <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun last()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置满足条件的最后一个。
|
||||
|
||||
#### reverse <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun reverse(num: Int)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置倒序下标。
|
@@ -0,0 +1,83 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# CountRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class CountRules private constructor()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 这是一个模糊 `Class`、`Member` 数组 (下标) 个数条件实现类。
|
||||
|
||||
可对 R8 混淆后的 `Class`、`Member` 进行更加详细的定位。
|
||||
|
||||
## Int.isZero <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun Int.isZero(): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 是否为 0。
|
||||
|
||||
## Int.moreThan <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun Int.moreThan(count: Int): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 大于 `count`。
|
||||
|
||||
## Int.lessThan <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun Int.lessThan(count: Int): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 小于 `count`。
|
||||
|
||||
## Int.inInterval <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun Int.inInterval(countRange: IntRange): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 在 `countRange` 区间 A ≤ this ≤ B。
|
@@ -0,0 +1,213 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# ModifierRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class ModifierRules private constructor()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 这是一个 `Class`、`Member` 描述符条件实现类。
|
||||
|
||||
可对 R8 混淆后的 `Class`、`Member` 进行更加详细的定位。
|
||||
|
||||
## isPublic <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isPublic: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Class`、`Member` 类型是否包含 `public`。
|
||||
|
||||
## isPrivate <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isPrivate: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Class`、`Member` 类型是否包含 `private`。
|
||||
|
||||
## isProtected <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isProtected: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Class`、`Member` 类型是否包含 `protected`。
|
||||
|
||||
## isStatic <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isStatic: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Class`、`Member` 类型是否包含 `static`。
|
||||
|
||||
对于任意的静态 `Class`、`Member` 可添加此描述进行确定。
|
||||
|
||||
::: warning
|
||||
|
||||
Kotlin → Jvm 后的 **object** 类中的方法并不是静态的。
|
||||
|
||||
:::
|
||||
|
||||
## isFinal <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isFinal: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Class`、`Member` 类型是否包含 `final`。
|
||||
|
||||
::: warning
|
||||
|
||||
Kotlin → Jvm 后没有 **open** 符号标识的 **Class**、**Member** 和没有任何关联的 **Class**、**Member** 都将为 **final**。
|
||||
|
||||
:::
|
||||
|
||||
## isSynchronized <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isSynchronized: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Class`、`Member` 类型是否包含 `synchronized`。
|
||||
|
||||
## isVolatile <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isVolatile: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Field` 类型是否包含 `volatile`。
|
||||
|
||||
## isTransient <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isTransient: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Field` 类型是否包含 `transient`。
|
||||
|
||||
## isNative <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isNative: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Method` 类型是否包含 `native`。
|
||||
|
||||
对于任意 JNI 对接的 `Method` 可添加此描述进行确定。
|
||||
|
||||
## isInterface <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isInterface: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Class` 类型是否包含 `interface`。
|
||||
|
||||
## isAbstract <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isAbstract: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Class`、`Member` 类型是否包含 `abstract`。
|
||||
|
||||
对于任意的抽象 `Class`、`Member` 可添加此描述进行确定。
|
||||
|
||||
## isStrict <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isStrict: Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Class`、`Member` 类型是否包含 `strictfp`。
|
@@ -0,0 +1,129 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# NameRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class NameRules private constructor()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 这是一个模糊 `Class`、`Member` 名称条件实现类。
|
||||
|
||||
可对 R8 混淆后的 `Class`、`Member` 进行更加详细的定位。
|
||||
|
||||
## String.isSynthetic <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.isSynthetic(index: Int): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 是否为匿名类的主类调用对象。
|
||||
|
||||
## String.isOnlySymbols <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.isOnlySymbols(): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 是否只有符号。
|
||||
|
||||
## String.isOnlyLetters <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.isOnlyLetters(): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 是否只有字母。
|
||||
|
||||
## String.isOnlyNumbers <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.isOnlyNumbers(): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 是否只有数字。
|
||||
|
||||
## String.isOnlyLettersNumbers <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.isOnlyLettersNumbers(): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 是否只有字母或数字。
|
||||
|
||||
## String.isOnlyLowercase <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.isOnlyLowercase(): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 是否只有小写字母。
|
||||
|
||||
在没有其它条件的情况下设置此条件允许判断对象存在字母以外的字符。
|
||||
|
||||
## String.isOnlyUppercase <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.isOnlyUppercase(): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 是否只有大写字母。
|
||||
|
||||
在没有其它条件的情况下设置此条件允许判断对象存在字母以外的字符。
|
@@ -0,0 +1,27 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# ObjectRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class ObjectRules private constructor(private val instance: Any)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 这是一个任意对象条件实现类。
|
||||
|
||||
可对 R8 混淆后的 `Class`、`Member` 进行更加详细的定位。
|
@@ -0,0 +1,734 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# DexClassFinder <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class DexClassFinder internal constructor(
|
||||
private val context: Context?,
|
||||
internal var name: String,
|
||||
internal var async: Boolean,
|
||||
override val loaderSet: ClassLoader?
|
||||
) : ClassBaseFinder
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Class` 查找类。
|
||||
|
||||
可使用 `BaseDexClassLoader` 通过指定条件查找指定 `Class` 或一组 `Class`。
|
||||
|
||||
::: warning
|
||||
|
||||
此功能尚在试验阶段,性能与稳定性可能仍然存在问题,使用过程遇到问题请向我们报告并帮助我们改进。
|
||||
|
||||
:::
|
||||
|
||||
## companion object <span class="symbol">- object</span>
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
### clearCache <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun clearCache(context: Context, versionName: String?, versionCode: Long?)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 清除当前 `DexClassFinder` 的 `Class` 缓存。
|
||||
|
||||
适用于全部通过 [ClassLoader.searchClass](../../../factory/ReflectionFactory#classloader-searchclass-ext-method) 获取的 `DexClassFinder`。
|
||||
|
||||
## fullName <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var fullName: String
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 完整名称。
|
||||
|
||||
只会查找匹配到的 `Class.getName`。
|
||||
|
||||
例如 `com.demo.Test` 需要填写 `com.demo.Test`。
|
||||
|
||||
## simpleName <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var simpleName: String
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 简单名称。
|
||||
|
||||
只会查找匹配到的 `Class.getSimpleName`。
|
||||
|
||||
例如 `com.demo.Test` 只需要填写 `Test`。
|
||||
|
||||
对于匿名类例如 `com.demo.Test$InnerTest` 会为空,此时你可以使用 [singleName](#singlename-field)。
|
||||
|
||||
## singleName <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var singleName: String
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 独立名称。
|
||||
|
||||
设置后将首先使用 `Class.getSimpleName`,若为空则会使用 `Class.getName` 进行处理。
|
||||
|
||||
例如 `com.demo.Test` 只需要填写 `Test`。
|
||||
|
||||
对于匿名类例如 `com.demo.Test$InnerTest` 只需要填写 `Test$InnerTest`。
|
||||
|
||||
## from <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun from(vararg name: String): FromPackageRules
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置在指定包名范围查找当前 `Class`。
|
||||
|
||||
设置后仅会在当前 `name` 开头匹配的包名路径下进行查找,可提升查找速度。
|
||||
|
||||
例如 ↓
|
||||
|
||||
`com.demo.test`
|
||||
|
||||
`com.demo.test.demo`
|
||||
|
||||
::: warning
|
||||
|
||||
建议设置此参数指定查找范围,否则 **Class** 过多时将会非常慢。
|
||||
|
||||
:::
|
||||
|
||||
## modifiers <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun modifiers(conditions: ModifierConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件。
|
||||
|
||||
## fullName <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun fullName(value: String): ClassNameRules
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 完整名称。
|
||||
|
||||
只会查找匹配到的 `Class.getName`。
|
||||
|
||||
例如 `com.demo.Test` 需要填写 `com.demo.Test`。
|
||||
|
||||
## simpleName <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun simpleName(value: String): ClassNameRules
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 简单名称。
|
||||
|
||||
只会查找匹配到的 `Class.getSimpleName`。
|
||||
|
||||
例如 `com.demo.Test` 只需要填写 `Test`。
|
||||
|
||||
对于匿名类例如 `com.demo.Test$InnerTest 会为空`,此时你可以使用 [singleName](#singlename-method)。
|
||||
|
||||
## singleName <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun singleName(value: String): ClassNameRules
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 独立名称。
|
||||
|
||||
设置后将首先使用 `Class.getSimpleName`,若为空则会使用 `Class.getName` 进行处理。
|
||||
|
||||
例如 `com.demo.Test` 只需要填写 `Test`。
|
||||
|
||||
对于匿名类例如 `com.demo.Test$InnerTest` 只需要填写 `Test$InnerTest`。
|
||||
|
||||
## fullName <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun fullName(conditions: NameConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 完整名称条件。
|
||||
|
||||
只会查找匹配到的 `Class.getName`。
|
||||
|
||||
## simpleName <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun simpleName(conditions: NameConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 简单名称条件。
|
||||
|
||||
只会查找匹配到的 `Class.getSimpleName`。
|
||||
|
||||
## singleName <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun singleName(conditions: NameConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 独立名称条件。
|
||||
|
||||
设置后将首先使用 `Class.getSimpleName`,若为空则会使用 `Class.getName` 进行处理。
|
||||
|
||||
## extends <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> extends()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 继承的父类。
|
||||
|
||||
## extends <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun extends(vararg name: String)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 继承的父类。
|
||||
|
||||
会同时查找 `name` 中所有匹配的父类。
|
||||
|
||||
## implements <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> implements()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 实现的接口类。
|
||||
|
||||
## implements <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun implements(vararg name: String)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 实现的接口类。
|
||||
|
||||
会同时查找 `name` 中所有匹配的接口类。
|
||||
|
||||
## anonymous <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun anonymous()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 标识 `Class` 为匿名类。
|
||||
|
||||
例如 `com.demo.Test$1` 或 `com.demo.Test$InnerTest`。
|
||||
|
||||
标识后你可以使用 [enclosing](#enclosing-method) 来进一步指定匿名类的 (封闭类) 主类。
|
||||
|
||||
## noExtends <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun noExtends()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 没有任何继承。
|
||||
|
||||
此时 `Class` 只应该继承于 `Any`。
|
||||
|
||||
::: warning
|
||||
|
||||
设置此条件后 [extends](#extends-method) 将失效。
|
||||
|
||||
:::
|
||||
|
||||
## noImplements <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun noImplements()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 没有任何接口。
|
||||
|
||||
::: warning
|
||||
|
||||
设置此条件后 [implements](#implements-method) 将失效。
|
||||
|
||||
:::
|
||||
|
||||
## noSuper <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun noSuper()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 没有任何继承与接口。
|
||||
|
||||
此时 `Class` 只应该继承于 `Any`。
|
||||
|
||||
::: warning
|
||||
|
||||
设置此条件后 [extends](#extends-method) 与 [implements](#implements-method) 将失效。
|
||||
|
||||
:::
|
||||
|
||||
## enclosing <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> enclosing()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 匿名类的 (封闭类) 主类。
|
||||
|
||||
## enclosing <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun enclosing(vararg name: String)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 匿名类的 (封闭类) 主类。
|
||||
|
||||
会同时查找 `name` 中所有匹配的 (封闭类) 主类。
|
||||
|
||||
## FromPackageRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class FromPackageRules internal constructor(private val packages: ArrayList<ClassRulesData.PackageRulesData>)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 包名范围名称过滤匹配条件实现类。
|
||||
|
||||
### absolute <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun absolute()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置包名绝对匹配。
|
||||
|
||||
例如有如下包名 ↓
|
||||
|
||||
`com.demo.test.a`
|
||||
|
||||
`com.demo.test.a.b`
|
||||
|
||||
`com.demo.test.active`
|
||||
|
||||
若包名条件为 `com.demo.test.a` 则绝对匹配仅能匹配到第一个。
|
||||
|
||||
相反地,不设置以上示例会全部匹配。
|
||||
|
||||
## ClassNameRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class ClassNameRules internal constructor(private val name: ClassRulesData.NameRulesData)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 类名匹配条件实现类。
|
||||
|
||||
### optional <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun optional()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置类名可选。
|
||||
|
||||
例如有如下类名 ↓
|
||||
|
||||
`com.demo.Test` **fullName** / `Test` **simpleName**
|
||||
|
||||
`defpackage.a` **fullName** / `a` **simpleName**
|
||||
|
||||
这两个类名都是同一个类,但是在有些版本中被混淆有些版本没有。
|
||||
|
||||
此时可设置类名为 `com.demo.Test` **fullName** / `Test` **simpleName**。
|
||||
|
||||
这样就可在完全匹配类名情况下使用类名而忽略其它查找条件,否则忽略此条件继续使用其它查找条件。
|
||||
|
||||
## member <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun member(initiate: MemberRules.() -> Unit): MemberRulesResult
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 满足的 `Member` 条件。
|
||||
|
||||
## field <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun field(initiate: FieldRules.() -> Unit): MemberRulesResult
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 满足的 `Field` 条件。
|
||||
|
||||
## method <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun method(initiate: MethodRules.() -> Unit): MemberRulesResult
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 满足的 `Method` 条件。
|
||||
|
||||
## constructor <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun constructor(initiate: ConstructorRules.() -> Unit): MemberRulesResult
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Class` 满足的 `Constructor` 条件。
|
||||
|
||||
## Result <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Result internal constructor(internal var isNotFound: Boolean, internal var throwable: Throwable?) : BaseResult
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Class` 查找结果实现类。
|
||||
|
||||
### result <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun result(initiate: Result.() -> Unit): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 创建监听结果事件方法体。
|
||||
|
||||
### get <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun get(): Class<*>?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到 `Class` 本身。
|
||||
|
||||
若有多个 `Class` 结果只会返回第一个。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回 `null`。
|
||||
|
||||
若你设置了 `async` 请使用 [wait](#wait-method) 方法。
|
||||
|
||||
### all <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun all(): HashSet<Class<*>>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到 `Class` 本身数组。
|
||||
|
||||
返回全部查找条件匹配的多个 `Class` 实例。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回空的 `HashSet`。
|
||||
|
||||
若你设置了 `async` 请使用 [waitAll](#waitall-method) 方法。
|
||||
|
||||
### all <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun all(result: (Class<*>) -> Unit): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到 `Class` 本身数组 (依次遍历)。
|
||||
|
||||
回调全部查找条件匹配的多个 `Class` 实例。
|
||||
|
||||
在查找条件找不到任何结果的时候将不会执行。
|
||||
|
||||
若你设置了 `async` 请使用 [waitAll](#waitall-method) 方法。
|
||||
|
||||
### wait <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun wait(result: (Class<*>?) -> Unit): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到 `Class` 本身 (异步)。
|
||||
|
||||
若有多个 `Class` 结果只会回调第一个。
|
||||
|
||||
在查找条件找不到任何结果的时候将回调 null。
|
||||
|
||||
你需要设置 `async` 后此方法才会被回调,否则请使用 [get](#get-method) 方法。
|
||||
|
||||
### waitAll <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun waitAll(result: (HashSet<Class<*>>) -> Unit): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到 `Class` 本身数组 (异步)。
|
||||
|
||||
回调全部查找条件匹配的多个 `Class` 实例。
|
||||
|
||||
在查找条件找不到任何结果的时候将回调空的 `HashSet`。
|
||||
|
||||
你需要设置 `async` 后此方法才会被回调,否则请使用 [all](#all-method) 方法。
|
||||
|
||||
### onNoClassDefFoundError <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun onNoClassDefFoundError(result: (Throwable) -> Unit): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 监听找不到 `Class` 时。
|
||||
|
||||
### ignored <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun ignored(): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 忽略异常并停止打印任何错误日志。
|
||||
|
||||
此时若要监听异常结果,你需要手动实现 [onNoClassDefFoundError](#onnoclassdeffounderror-method) 方法。
|
@@ -0,0 +1,153 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# ConstructorRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class ConstructorRules internal constructor(internal val rulesData: ConstructorRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Constructor` 查找条件实现类。
|
||||
|
||||
## paramCount <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var paramCount: Int
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Constructor` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此变量指定参数个数。
|
||||
|
||||
若参数个数小于零则忽略并使用 `param`。
|
||||
|
||||
## modifiers <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun modifiers(conditions: ModifierConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Constructor` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件。
|
||||
|
||||
## emptyParam <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun emptyParam()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Constructor` 空参数、无参数。
|
||||
|
||||
## param <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun param(vararg paramType: Any)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Constructor` 参数。
|
||||
|
||||
如果同时使用了 `paramCount` 则 `paramType` 的数量必须与 `paramCount` 完全匹配。
|
||||
|
||||
如果 `Constructor` 中存在一些无意义又很长的类型,你可以使用 `VagueType` 来替代它。
|
||||
|
||||
::: danger
|
||||
|
||||
无参 **Constructor** 请使用 **emptyParam** 设置查找条件。
|
||||
|
||||
有参 **Constructor** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
|
||||
|
||||
:::
|
||||
|
||||
## param <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun param(conditions: ObjectsConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Constructor` 参数条件。
|
||||
|
||||
::: danger
|
||||
|
||||
无参 **Constructor** 请使用 **emptyParam** 设置查找条件。
|
||||
|
||||
有参 **Constructor** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(numRange: IntRange)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Constructor` 参数个数范围。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数范围。
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(conditions: CountConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Constructor` 参数个数条件。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数条件。
|
@@ -0,0 +1,101 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# FieldRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class FieldRules internal constructor(internal val rulesData: FieldRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Field` 查找条件实现类。
|
||||
|
||||
## name <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var name: String
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Field` 名称。
|
||||
|
||||
## type <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var type: Any?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Field` 类型。
|
||||
|
||||
可不填写类型。
|
||||
|
||||
## modifiers <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun modifiers(conditions: ModifierConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Field` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件。
|
||||
|
||||
## name <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun name(conditions: NameConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Field` 名称条件。
|
||||
|
||||
## type <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun type(conditions: ObjectConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Field` 类型条件。
|
||||
|
||||
可不填写类型。
|
@@ -0,0 +1,41 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# MemberRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class MemberRules internal constructor(internal val rulesData: MemberRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Member` 查找条件实现类。
|
||||
|
||||
## modifiers <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun modifiers(conditions: ModifierConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Member` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件。
|
@@ -0,0 +1,213 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# MethodRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class MethodRules internal constructor(internal val rulesData: MethodRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Method` 查找条件实现类。
|
||||
|
||||
## name <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var name: String
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 名称。
|
||||
|
||||
## paramCount <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var paramCount: Int
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此变量指定参数个数。
|
||||
|
||||
若参数个数小于零则忽略并使用 `param`。
|
||||
|
||||
## returnType <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var returnType: Any?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 返回值。
|
||||
|
||||
可不填写返回值。
|
||||
|
||||
## modifiers <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun modifiers(conditions: ModifierConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件。
|
||||
|
||||
## emptyParam <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun emptyParam()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 空参数、无参数。
|
||||
|
||||
## param <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun param(vararg paramType: Any)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 参数。
|
||||
|
||||
如果同时使用了 `paramCount` 则 `paramType` 的数量必须与 `paramCount` 完全匹配。
|
||||
|
||||
如果 `Method` 中存在一些无意义又很长的类型,你可以使用 `VagueType` 来替代它。
|
||||
|
||||
::: danger
|
||||
|
||||
无参 **Method** 请使用 **emptyParam** 设置查找条件。
|
||||
|
||||
有参 **Method** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
|
||||
|
||||
:::
|
||||
|
||||
## param <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun param(conditions: ObjectsConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 参数条件。
|
||||
|
||||
::: danger
|
||||
|
||||
无参 **Method** 请使用 **emptyParam** 设置查找条件。
|
||||
|
||||
有参 **Method** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
|
||||
|
||||
:::
|
||||
|
||||
## name <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun name(conditions: NameConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 名称条件。
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(numRange: IntRange)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 参数个数范围。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数范围。
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(conditions: CountConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 参数个数条件。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数条件。
|
||||
|
||||
## returnType <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun returnType(conditions: ObjectConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 返回值条件。
|
||||
|
||||
可不填写返回值。
|
@@ -0,0 +1,81 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# MemberRulesResult <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class MemberRulesResult internal constructor(private val rulesData: MemberRulesData)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 当前 `Member` 查找条件结果实现类。
|
||||
|
||||
## none <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun none(): MemberRulesResult
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置当前 `Member` 在查找条件中个数为 `0`。
|
||||
|
||||
## count <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun count(num: Int): MemberRulesResult
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置当前 `Member` 在查找条件中需要全部匹配的个数。
|
||||
|
||||
## count <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun count(numRange: IntRange): MemberRulesResult
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置当前 `Member` 在查找条件中需要全部匹配的个数范围。
|
||||
|
||||
## count <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun count(conditions: CountConditions): MemberRulesResult
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置当前 `Member` 在查找条件中需要全部匹配的个数条件。
|
@@ -0,0 +1,623 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# ConstructorFinder <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class ConstructorFinder internal constructor(override val classSet: Class<*>) : MemberBaseFinder
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Constructor` 查找类。
|
||||
|
||||
可通过指定类型查找指定 `Constructor` 或一组 `Constructor`。
|
||||
|
||||
## paramCount <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var paramCount: Int
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Constructor` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此变量指定参数个数。
|
||||
|
||||
若参数个数小于零则忽略并使用 `param`。
|
||||
|
||||
## modifiers <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun modifiers(conditions: ModifierConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Constructor` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件,默认模糊查找并取第一个匹配的 `Constructor`。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## emptyParam <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun emptyParam(): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Constructor` 空参数、无参数。
|
||||
|
||||
## param <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun param(vararg paramType: Any): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Constructor` 参数。
|
||||
|
||||
如果同时使用了 `paramCount` 则 `paramType` 的数量必须与 `paramCount` 完全匹配。
|
||||
|
||||
如果 `Constructor` 中存在一些无意义又很长的类型,你可以使用 [VagueType](../../../type/defined/DefinedTypeFactory#vaguetype-field) 来替代它。
|
||||
|
||||
::: danger
|
||||
|
||||
无参 **Constructor** 请使用 **emptyParam** 设置查找条件。
|
||||
|
||||
有参 **Constructor** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## param <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun param(conditions: ObjectsConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Constructor` 参数条件。
|
||||
|
||||
::: danger
|
||||
|
||||
无参 **Constructor** 请使用 **emptyParam** 设置查找条件。
|
||||
|
||||
有参 **Constructor** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(num: Int): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Constructor` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数。
|
||||
|
||||
若参数个数小于零则忽略并使用 `param`。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(numRange: IntRange): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Constructor` 参数个数范围。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数范围。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(conditions: CountConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Constructor` 参数个数条件。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数条件。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## superClass <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun superClass(isOnlySuperClass: Boolean)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置在 `classSet` 的所有父类中查找当前 `Constructor`。
|
||||
|
||||
::: warning
|
||||
|
||||
若当前 **classSet** 的父类较多可能会耗时,API 会自动循环到父类继承是 **Any** 前的最后一个类。
|
||||
|
||||
:::
|
||||
|
||||
## RemedyPlan <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class RemedyPlan internal constructor()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Constructor` 重查找实现类,可累计失败次数直到查找成功。
|
||||
|
||||
### constructor <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun constructor(initiate: ConstructorConditions)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 创建需要重新查找的 `Constructor`。
|
||||
|
||||
你可以添加多个备选 `Constructor`,直到成功为止,若最后依然失败,将停止查找并输出错误日志。
|
||||
|
||||
### Result <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Result internal constructor()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `RemedyPlan` 结果实现类。
|
||||
|
||||
#### onFind <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun onFind(initiate: HashSet<Constructor<*>>.() -> Unit)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 当在 `RemedyPlan` 中找到结果时。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以方便地对重查找的 `Constructor` 实现 `onFind` 方法。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
constructor {
|
||||
// Your code here.
|
||||
}.onFind {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
## Result <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, internal val throwable: Throwable?) : BaseResult
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Constructor` 查找结果实现类。
|
||||
|
||||
### result <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun result(initiate: Result.() -> Unit): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 创建监听结果事件方法体。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以使用 `lambda` 形式创建 `Result` 类。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
constructor {
|
||||
// Your code here.
|
||||
}.result {
|
||||
get().call()
|
||||
all()
|
||||
remedys {}
|
||||
onNoSuchConstructor {}
|
||||
}
|
||||
```
|
||||
|
||||
### get <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun get(): Instance
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得 `Constructor` 实例处理类。
|
||||
|
||||
若有多个 `Constructor` 结果只会返回第一个。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 请使用 **wait** 回调结果方法。
|
||||
|
||||
:::
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以通过获得方法所在实例来执行构造方法创建新的实例对象。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
constructor {
|
||||
// Your code here.
|
||||
}.get().call()
|
||||
```
|
||||
|
||||
你可以 `cast` 构造方法为指定类型的实例对象。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
constructor {
|
||||
// Your code here.
|
||||
}.get().newInstance<TestClass>()
|
||||
```
|
||||
|
||||
::: danger
|
||||
|
||||
若构造方法含有参数则后方参数必填。
|
||||
|
||||
:::
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
constructor {
|
||||
// Your code here.
|
||||
}.get().newInstance<TestClass>("param1", "param2")
|
||||
```
|
||||
|
||||
### all <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun all(): ArrayList<Instance>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得 `Constructor` 实例处理类数组。
|
||||
|
||||
返回全部查找条件匹配的多个 `Constructor` 实例结果。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以通过此方法来获得当前条件结果中匹配的全部 `Constructor`。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
constructor {
|
||||
// Your code here.
|
||||
}.all().forEach { instance ->
|
||||
instance.call(...)
|
||||
}
|
||||
```
|
||||
|
||||
### give <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun give(): Constructor<*>?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到 `Constructor` 本身。
|
||||
|
||||
若有多个 `Constructor` 结果只会返回第一个。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回 `null`。
|
||||
|
||||
### giveAll <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun giveAll(): HashSet<Constructor<*>>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到 `Constructor` 本身数组。
|
||||
|
||||
返回全部查找条件匹配的多个 `Constructor` 实例。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回空的 `HashSet`。
|
||||
|
||||
### wait <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun wait(initiate: Instance.() -> Unit)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得 `Constructor` 实例处理类,配合 `RemedyPlan` 使用。
|
||||
|
||||
若有多个 `Constructor` 结果只会返回第一个。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 必须使用此方法才能获得结果。
|
||||
|
||||
若你没有设置 **remedys** 此方法将不会被回调。
|
||||
|
||||
:::
|
||||
|
||||
### waitAll <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun waitAll(initiate: ArrayList<Instance>.() -> Unit)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得 `Constructor` 实例处理类数组,配合 `RemedyPlan` 使用。
|
||||
|
||||
返回全部查找条件匹配的多个 `Constructor` 实例结果。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 必须使用此方法才能获得结果。
|
||||
|
||||
若你没有设置 **remedys** 此方法将不会被回调。
|
||||
|
||||
:::
|
||||
|
||||
### remedys <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun remedys(initiate: RemedyPlan.() -> Unit): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 创建 `Constructor` 重查找功能。
|
||||
|
||||
**Function Example**
|
||||
|
||||
当你遇到一种 `Constructor` 可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchConstructor` 捕获异常二次查找 `Constructor`。
|
||||
|
||||
若第一次查找失败了,你还可以在这里继续添加此方法体直到成功为止。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
constructor {
|
||||
// Your code here.
|
||||
}.remedys {
|
||||
constructor {
|
||||
// Your code here.
|
||||
}
|
||||
constructor {
|
||||
// Your code here.
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### onNoSuchConstructor <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun onNoSuchConstructor(result: (Throwable) -> Unit): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 监听找不到 `Constructor` 时。
|
||||
|
||||
只会返回第一次的错误信息,不会返回 `RemedyPlan` 的错误信息。
|
||||
|
||||
### ignored <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun ignored(): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 忽略异常并停止打印任何错误日志。
|
||||
|
||||
::: warning
|
||||
|
||||
此时若要监听异常结果,你需要手动实现 **onNoSuchConstructor** 方法。
|
||||
|
||||
:::
|
||||
|
||||
### Instance <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Instance internal constructor(private val constructor: Constructor<*>?)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Constructor` 实例处理类。
|
||||
|
||||
#### call <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun call(vararg args: Any?): Any?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 执行 `Constructor` 创建目标实例,不指定目标实例类型。
|
||||
|
||||
#### newInstance <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun <T> newInstance(vararg args: Any?): T?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 执行 `Constructor` 创建目标实例 ,指定 `T` 目标实例类型。
|
@@ -0,0 +1,827 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# FieldFinder <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class FieldFinder internal constructor(override val classSet: Class<*>?) : MemberBaseFinder
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Field` 查找类。
|
||||
|
||||
可通过指定类型查找指定 `Field` 或一组 `Field`。
|
||||
|
||||
## name <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var name: String
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Field` 名称。
|
||||
|
||||
::: danger
|
||||
|
||||
若不填写名称则必须存在一个其它条件。
|
||||
|
||||
:::
|
||||
|
||||
## type <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var type: Any?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Field` 类型。
|
||||
|
||||
可不填写类型。
|
||||
|
||||
## modifiers <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun modifiers(conditions: ModifierConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Field` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## order <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun order(): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 顺序筛选字节码的下标。
|
||||
|
||||
## name <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun name(value: String): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Field` 名称。
|
||||
|
||||
::: danger
|
||||
|
||||
若不填写名称则必须存在一个其它条件。
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## name <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun name(conditions: NameConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Field` 名称条件。
|
||||
|
||||
::: danger
|
||||
|
||||
若不填写名称则必须存在一个其它条件。
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## type <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun type(value: Any): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Field` 类型。
|
||||
|
||||
可不填写类型。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## type <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun type(conditions: ObjectConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Field` 类型条件。
|
||||
|
||||
可不填写类型。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## superClass <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun superClass(isOnlySuperClass: Boolean)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置在 `classSet` 的所有父类中查找当前 `Field`。
|
||||
|
||||
::: warning
|
||||
|
||||
若当前 **classSet** 的父类较多可能会耗时,API 会自动循环到父类继承是 **Any** 前的最后一个类。
|
||||
|
||||
:::
|
||||
|
||||
## RemedyPlan <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class RemedyPlan internal constructor()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Field` 重查找实现类,可累计失败次数直到查找成功。
|
||||
|
||||
### field <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun field(initiate: FieldConditions): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 创建需要重新查找的 `Field`。
|
||||
|
||||
你可以添加多个备选 `Field`,直到成功为止,若最后依然失败,将停止查找并输出错误日志。
|
||||
|
||||
### Result <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Result internal constructor()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `RemedyPlan` 结果实现类。
|
||||
|
||||
#### onFind <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun onFind(initiate: HashSet<Field>.() -> Unit)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 当在 `RemedyPlan` 中找到结果时。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以方便地对重查找的 `Field` 实现 `onFind` 方法。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
// Your code here.
|
||||
}.onFind {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
## Result <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, private val throwable: Throwable?) : BaseResult
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Field` 查找结果实现类。
|
||||
|
||||
### result <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun result(initiate: Result.() -> Unit): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 创建监听结果事件方法体。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以使用 `lambda` 形式创建 `Result` 类。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
// Your code here.
|
||||
}.result {
|
||||
get(instance).set("something")
|
||||
get(instance).string()
|
||||
get(instance).cast<CustomClass>()
|
||||
get().boolean()
|
||||
all(instance)
|
||||
give()
|
||||
giveAll()
|
||||
onNoSuchField {}
|
||||
}
|
||||
```
|
||||
|
||||
### get <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun get(instance: Any?): Instance
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得 `Field` 实例处理类。
|
||||
|
||||
若有多个 `Field` 结果只会返回第一个。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以轻松地得到 `Field` 的实例以及使用它进行设置实例。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
// Your code here.
|
||||
}.get(instance).set("something")
|
||||
```
|
||||
|
||||
如果你取到的是静态 `Field`,可以不需要设置实例。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
// Your code here.
|
||||
}.get().set("something")
|
||||
```
|
||||
|
||||
### all <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun all(instance: Any?): ArrayList<Instance>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得 `Field` 实例处理类数组。
|
||||
|
||||
返回全部查找条件匹配的多个 `Field` 实例结果。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以通过此方法来获得当前条件结果中匹配的全部 `Field`,其 `Field` 所在实例用法与 `get` 相同。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
// Your code here.
|
||||
}.all(instance).forEach { instance ->
|
||||
instance.self
|
||||
}
|
||||
```
|
||||
|
||||
### give <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun give(): Field?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到 `Field` 本身。
|
||||
|
||||
若有多个 Field 结果只会返回第一个。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回 `null`。
|
||||
|
||||
### giveAll <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun giveAll(): HashSet<Field>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到 `Field` 本身数组。
|
||||
|
||||
返回全部查找条件匹配的多个 `Field` 实例。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回空的 `HashSet`。
|
||||
|
||||
### wait <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun wait(instance: Any?, initiate: Instance.() -> Unit)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得 `Field` 实例处理类,配合 `RemedyPlan` 使用。
|
||||
|
||||
若有多个 `Field` 结果只会返回第一个。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 必须使用此方法才能获得结果。
|
||||
|
||||
若你没有设置 **remedys** 此方法将不会被回调。
|
||||
|
||||
:::
|
||||
|
||||
### waitAll <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun waitAll(instance: Any?, initiate: ArrayList<Instance>.() -> Unit)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得 `Field` 实例处理类数组,配合 `RemedyPlan` 使用。
|
||||
|
||||
返回全部查找条件匹配的多个 `Field` 实例结果。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 必须使用此方法才能获得结果。
|
||||
|
||||
若你没有设置 **remedys** 此方法将不会被回调。
|
||||
|
||||
:::
|
||||
|
||||
### remedys <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun remedys(initiate: RemedyPlan.() -> Unit): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 创建 `Field` 重查找功能。
|
||||
|
||||
**Function Example**
|
||||
|
||||
当你遇到一种 `Field` 可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchField` 捕获异常二次查找 `Field`。
|
||||
|
||||
若第一次查找失败了,你还可以在这里继续添加此方法体直到成功为止。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
// Your code here.
|
||||
}.remedys {
|
||||
field {
|
||||
// Your code here.
|
||||
}
|
||||
field {
|
||||
// Your code here.
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### onNoSuchField <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun onNoSuchField(result: (Throwable) -> Unit): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 监听找不到 `Field` 时。
|
||||
|
||||
### ignored <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun ignored(): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 忽略异常并停止打印任何错误日志。
|
||||
|
||||
::: warning
|
||||
|
||||
此时若要监听异常结果,你需要手动实现 **onNoSuchField** 方法。
|
||||
|
||||
:::
|
||||
|
||||
### Instance <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Instance internal constructor(private val instance: Any?, private val field: Field?)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Field` 实例变量处理类。
|
||||
|
||||
#### current <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun current(ignored: Boolean): CurrentClass?
|
||||
```
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun current(ignored: Boolean, initiate: CurrentClass.() -> Unit): Any?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得当前 `Field` 自身 `self` 实例的类操作对象 `CurrentClass`。
|
||||
|
||||
#### cast <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun <T> cast(): T?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到当前 `Field` 实例。
|
||||
|
||||
#### byte <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun byte(): Byte?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到当前 `Field` Byte 实例。
|
||||
|
||||
#### int <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun int(): Int
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到当前 `Field` Int 实例。
|
||||
|
||||
#### long <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun long(): Long
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到当前 `Field` Long 实例。
|
||||
|
||||
#### short <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun short(): Short
|
||||
```
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到当前 `Field` Short 实例。
|
||||
|
||||
#### double <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun double(): Double
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到当前 `Field` Double 实例。
|
||||
|
||||
#### float <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun float(): Float
|
||||
```
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到当前 `Field` Float 实例。
|
||||
|
||||
#### string <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun string(): String
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到当前 `Field` String 实例。
|
||||
|
||||
#### char <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun char(): Char
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到当前 `Field` Char 实例。
|
||||
|
||||
#### boolean <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun boolean(): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到当前 `Field` Boolean 实例。
|
||||
|
||||
#### any <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun any(): Any?
|
||||
```
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到当前 `Field` Any 实例。
|
||||
|
||||
#### array <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> array(): Array<T>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到当前 `Field` Array 实例。
|
||||
|
||||
#### list <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> list(): List<T>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到当前 `Field` List 实例。
|
||||
|
||||
#### set <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun set(any: Any?)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置当前 `Field` 实例。
|
||||
|
||||
#### setTrue <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun setTrue()
|
||||
```
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置当前 `Field` 实例为 `true`。
|
||||
|
||||
::: danger
|
||||
|
||||
请确保实例对象类型为 **Boolean**。
|
||||
|
||||
:::
|
||||
|
||||
#### setFalse <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun setFalse()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置当前 `Field` 实例为 `false`。
|
||||
|
||||
::: danger
|
||||
|
||||
请确保实例对象类型为 **Boolean**。
|
||||
|
||||
:::
|
||||
|
||||
#### setNull <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun setNull()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置当前 `Field` 实例为 `null`。
|
@@ -0,0 +1,899 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# MethodFinder <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class MethodFinder internal constructor(override val classSet: Class<*>) : MemberBaseFinder
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Method` 查找类。
|
||||
|
||||
可通过指定类型查找指定 `Method` 或一组 `Method`。
|
||||
|
||||
## name <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var name: String
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 名称。
|
||||
|
||||
::: danger
|
||||
|
||||
若不填写名称则必须存在一个其它条件。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var paramCount: Int
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此变量指定参数个数。
|
||||
|
||||
若参数个数小于零则忽略并使用 `param`。
|
||||
|
||||
## returnType <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var returnType: Any?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 返回值,可不填写返回值。
|
||||
|
||||
## modifiers <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun modifiers(conditions: ModifierConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## emptyParam <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun emptyParam(): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 空参数、无参数。
|
||||
|
||||
## param <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun param(vararg paramType: Any): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 参数。
|
||||
|
||||
如果同时使用了 `paramCount` 则 `paramType` 的数量必须与 `paramCount` 完全匹配。
|
||||
|
||||
如果 `Method` 中存在一些无意义又很长的类型,你可以使用 [VagueType](../../../type/defined/DefinedTypeFactory#vaguetype-field) 来替代它。
|
||||
|
||||
::: danger
|
||||
|
||||
无参 **Method** 请使用 **emptyParam** 设置查找条件。
|
||||
|
||||
有参 **Method** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## param <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun param(conditions: ObjectsConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 参数条件。
|
||||
|
||||
::: danger
|
||||
|
||||
无参 **Method** 请使用 **emptyParam** 设置查找条件。
|
||||
|
||||
有参 **Method** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## order <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun order(): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 顺序筛选字节码的下标。
|
||||
|
||||
## name <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun name(value: String): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 名称。
|
||||
|
||||
::: danger
|
||||
|
||||
若不填写名称则必须存在一个其它条件。
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## name <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun name(conditions: NameConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 名称条件。
|
||||
|
||||
::: danger
|
||||
|
||||
若不填写名称则必须存在一个其它条件。
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(num: Int): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数。
|
||||
|
||||
若参数个数小于零则忽略并使用 `param`。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(numRange: IntRange): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 参数个数范围。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数范围。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(conditions: CountConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 参数个数条件。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数条件。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## returnType <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun returnType(value: Any): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 返回值。
|
||||
|
||||
可不填写返回值。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## returnType <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun returnType(conditions: ObjectConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置 `Method` 返回值条件。
|
||||
|
||||
可不填写返回值。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## superClass <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun superClass(isOnlySuperClass: Boolean)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 设置在 `classSet` 的所有父类中查找当前 `Method`。
|
||||
|
||||
::: warning
|
||||
|
||||
若当前 **classSet** 的父类较多可能会耗时,API 会自动循环到父类继承是 **Any** 前的最后一个类。
|
||||
|
||||
:::
|
||||
|
||||
## RemedyPlan <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class RemedyPlan internal constructor()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Method` 重查找实现类,可累计失败次数直到查找成功。
|
||||
|
||||
### method <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun method(initiate: MethodConditions): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 创建需要重新查找的 `Method`。
|
||||
|
||||
你可以添加多个备选 `Method`,直到成功为止,若最后依然失败,将停止查找并输出错误日志。
|
||||
|
||||
### Result <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Result internal constructor()
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `RemedyPlan` 结果实现类。
|
||||
|
||||
#### onFind <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun onFind(initiate: HashSet<Method>.() -> Unit)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 当在 `RemedyPlan` 中找到结果时。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以方便地对重查找的 `Method` 实现 `onFind` 方法。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
// Your code here.
|
||||
}.onFind {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
## Result <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, private val throwable: Throwable?) : BaseResult
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Method` 查找结果实现类。
|
||||
|
||||
### result <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun result(initiate: Result.() -> Unit): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 创建监听结果事件方法体。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以使用 `lambda` 形式创建 `Result` 类。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
// Your code here.
|
||||
}.result {
|
||||
get(instance).call()
|
||||
all(instance)
|
||||
remedys {}
|
||||
onNoSuchMethod {}
|
||||
}
|
||||
```
|
||||
|
||||
### get <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun get(instance: Any?): Instance
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得 `Method` 实例处理类。
|
||||
|
||||
若有多个 `Method` 结果只会返回第一个。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 请使用 **wait** 回调结果方法。
|
||||
|
||||
:::
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以通过获得方法所在实例来执行 `Method`。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
// Your code here.
|
||||
}.get(instance).call()
|
||||
```
|
||||
|
||||
若当前为静态方法,你可以不设置实例。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
// Your code here.
|
||||
}.get().call()
|
||||
```
|
||||
|
||||
### all <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun all(instance: Any?): ArrayList<Instance>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得 `Method` 实例处理类数组。
|
||||
|
||||
返回全部查找条件匹配的多个 `Method` 实例结果。
|
||||
|
||||
**Function Example**
|
||||
|
||||
你可以通过此方法来获得当前条件结果中匹配的全部 `Method`,其方法所在实例用法与 `get` 相同。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
// Your code here.
|
||||
}.all(instance).forEach { instance ->
|
||||
instance.call(...)
|
||||
}
|
||||
```
|
||||
|
||||
### give <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun give(): Method?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到 `Method` 本身。
|
||||
|
||||
若有多个 `Method` 结果只会返回第一个。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回 `null`。
|
||||
|
||||
### giveAll <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun giveAll(): HashSet<Method>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到 `Method` 本身数组。
|
||||
|
||||
返回全部查找条件匹配的多个 `Method` 实例。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回空的 `HashSet`。
|
||||
|
||||
### wait <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun wait(instance: Any?, initiate: Instance.() -> Unit)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得 `Method` 实例处理类,配合 `RemedyPlan` 使用。
|
||||
|
||||
若有多个 `Method` 结果只会返回第一个。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 必须使用此方法才能获得结果。
|
||||
|
||||
若你没有设置 **remedys** 此方法将不会被回调。
|
||||
|
||||
:::
|
||||
|
||||
### waitAll <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun waitAll(instance: Any?, initiate: ArrayList<Instance>.() -> Unit)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 获得 `Method` 实例处理类数组,配合 `RemedyPlan` 使用。
|
||||
|
||||
返回全部查找条件匹配的多个 `Method` 实例结果。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 必须使用此方法才能获得结果。
|
||||
|
||||
若你没有设置 **remedys** 此方法将不会被回调。
|
||||
|
||||
:::
|
||||
|
||||
### remedys <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun remedys(initiate: RemedyPlan.() -> Unit): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 创建 `Method` 重查找功能。
|
||||
|
||||
**Function Example**
|
||||
|
||||
当你遇到一种 `Method` 可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchMethod` 捕获异常二次查找 `Method`。
|
||||
|
||||
若第一次查找失败了,你还可以在这里继续添加此方法体直到成功为止。
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
// Your code here.
|
||||
}.remedys {
|
||||
method {
|
||||
// Your code here.
|
||||
}
|
||||
method {
|
||||
// Your code here.
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### onNoSuchMethod <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun onNoSuchMethod(result: (Throwable) -> Unit): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 监听找不到 `Method` 时。
|
||||
|
||||
只会返回第一次的错误信息,不会返回 `RemedyPlan` 的错误信息。
|
||||
|
||||
### ignored <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun ignored(): Result
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 忽略异常并停止打印任何错误日志。
|
||||
|
||||
::: warning
|
||||
|
||||
此时若要监听异常结果,你需要手动实现 **onNoSuchMethod** 方法。
|
||||
|
||||
:::
|
||||
|
||||
### Instance <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Instance internal constructor(private val instance: Any?, private val method: Method?)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> `Method` 实例处理类。
|
||||
|
||||
#### call <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun call(vararg args: Any?): Any?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 执行 `Method`,不指定返回值类型。
|
||||
|
||||
#### invoke <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun <T> invoke(vararg args: Any?): T?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 执行 `Method`,指定 `T` 返回值类型。
|
||||
|
||||
#### byte <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun byte(vararg args: Any?): Byte?
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 执行 `Method`,指定 Byte 返回值类型。
|
||||
|
||||
#### int <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun int(vararg args: Any?): Int
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 执行 `Method`,指定 Int 返回值类型。
|
||||
|
||||
#### long <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun long(vararg args: Any?): Long
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 执行 `Method`,指定 Long 返回值类型。
|
||||
|
||||
#### short <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun short(vararg args: Any?): Short
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 执行 `Method`,指定 Short 返回值类型。
|
||||
|
||||
#### double <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun double(vararg args: Any?): Double
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 执行 `Method`,指定 Double 返回值类型。
|
||||
|
||||
#### float <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun float(vararg args: Any?): Float
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 执行 `Method`,指定 Float 返回值类型。
|
||||
|
||||
#### string <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun string(vararg args: Any?): String
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 执行 `Method`,指定 String 返回值类型。
|
||||
|
||||
#### char <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun char(vararg args: Any?): Char
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 执行 `Method`,指定 Char 返回值类型。
|
||||
|
||||
#### boolean <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun boolean(vararg args: Any?): Boolean
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 执行 `Method`,指定 Boolean 返回值类型。
|
||||
|
||||
### array <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> array(vararg args: Any?): Array<T>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 执行 `Method`,指定 Array 返回值类型。
|
||||
|
||||
### list <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> list(vararg args: Any?): List<T>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 执行 `Method`,指定 List 返回值类型。
|
@@ -0,0 +1,23 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# ComponentTypeFactory <span class="symbol">- kt</span>
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 这是一个预置反射类型的常量类,主要为 `Android` 相关组件的 `Class` 内容,跟随版本更新会逐一进行增加。
|
||||
|
||||
详情可 [点击这里](https://github.com/fankes/YukiReflection/blob/master/yukireflection/src/api/kotlin/com/highcapable/yukireflection/type/android/ComponentTypeFactory.kt) 进行查看。
|
@@ -0,0 +1,23 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# GraphicsTypeFactory <span class="symbol">- kt</span>
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 这是一个预置反射类型的常量类,主要为 `Android` 相关 `Graphics` 的 `Class` 内容,跟随版本更新会逐一进行增加。
|
||||
|
||||
详情可 [点击这里](https://github.com/fankes/YukiReflection/blob/master/yukireflection/src/api/kotlin/com/highcapable/yukireflection/type/android/GraphicsTypeFactory.kt) 进行查看。
|
@@ -0,0 +1,23 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# ViewTypeFactory <span class="symbol">- kt</span>
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 这是一个预置反射类型的常量类,主要为 `Android` 相关 `Widget` 的 `Class` 内容,跟随版本更新会逐一进行增加。
|
||||
|
||||
详情可 [点击这里](https://github.com/fankes/YukiReflection/blob/master/yukireflection/src/api/kotlin/com/highcapable/yukireflection/type/android/ViewTypeFactory.kt) 进行查看。
|
@@ -0,0 +1,35 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# DefinedTypeFactory <span class="symbol">- kt</span>
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 这是一个内部类型的定义常量类,主要用于反射 API 相关用法的延伸。
|
||||
|
||||
## VagueType <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val VagueType: Class<*>
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 得到模糊类型。
|
@@ -0,0 +1,23 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
::: warning
|
||||
|
||||
The English translation of this page has not been completed, you are welcome to contribute translations to us.
|
||||
|
||||
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
|
||||
|
||||
:::
|
||||
|
||||
# VariableTypeFactory <span class="symbol">- kt</span>
|
||||
|
||||
**Change Records**
|
||||
|
||||
`v1.0.0` `added`
|
||||
|
||||
**Function Illustrate**
|
||||
|
||||
> 这是一个预置反射类型的常量类,主要为 `Java` 相关基本变量类型的 `Class` 内容,跟随版本更新会逐一进行增加。
|
||||
|
||||
详情可 [点击这里](https://github.com/fankes/YukiReflection/blob/master/yukireflection/src/api/kotlin/com/highcapable/yukireflection/type/java/VariableTypeFactory.kt) 进行查看。
|
121
docs-source/src/en/config/api-example.md
Normal file
@@ -0,0 +1,121 @@
|
||||
# API Basic Configs
|
||||
|
||||
> The basic configuration method of `YukiReflection` is introduced here.
|
||||
|
||||
`YukiReflection` can be used directly without some complex configuration, and does not conflict with `Java`'s native Reflection API.
|
||||
|
||||
You can configure some functions of `YukiReflection` before using it.
|
||||
|
||||
## Get the API Version
|
||||
|
||||
You can get the current API version of `YukiReflection` as follows.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// Get the version name
|
||||
val versionName = YukiReflection. API_VERSION_NAME
|
||||
// Get the version code
|
||||
val versionCode = YukiReflection. API_VERSION_CODE
|
||||
```
|
||||
|
||||
You can judge the difference between different versions or display it in the about information by obtaining the version.
|
||||
|
||||
::: tip
|
||||
|
||||
For more functions, please refer to [YukiReflection](../api/public/com/highcapable/yukireflection/YukiReflection).
|
||||
|
||||
:::
|
||||
|
||||
## Configure API Related Functions
|
||||
|
||||
You can configure related functions through `YukiReflection.configs { ... }` method or `YukiReflection.Configs`.
|
||||
|
||||
### Custom Debug Log Tag
|
||||
|
||||
You can use the following methods to customize the tag of the debug log.
|
||||
|
||||
Logs inside the API will be printed using this tag.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// Via the configs method
|
||||
YukiReflection.configs {
|
||||
debugTag = "YourCustomTag"
|
||||
}
|
||||
// Set directly
|
||||
YukiReflection.Configs.debugTag = "YourCustomTag"
|
||||
```
|
||||
|
||||
### Enable or Disable Debug Mode
|
||||
|
||||
You can use the following methods to enable or disable Debug mode.
|
||||
|
||||
The Debug mode is disabled by default, and when enabled, detailed logs (such as the time spent on the reflective search function) will be printed to the console.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// Via the configs method
|
||||
YukiReflection.configs {
|
||||
isDebug = true
|
||||
}
|
||||
// Set directly
|
||||
YukiReflection.Configs.isDebug = true
|
||||
```
|
||||
|
||||
### Enable or Disable Debug Logs
|
||||
|
||||
You can use the following methods to enable or disable debug logs.
|
||||
|
||||
This function is enabled by default, and disable will stop `YukiReflection` output all logs.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// Via the configs method
|
||||
YukiReflection.configs {
|
||||
isAllowPrintingLogs = true
|
||||
}
|
||||
// Set directly
|
||||
YukiReflection.Configs.isAllowPrintingLogs = true
|
||||
```
|
||||
|
||||
### Enable or Disable Member Cache
|
||||
|
||||
You can enable or disable `Member` caching as follows.
|
||||
|
||||
To prevent system GC problems caused by excessive `Member` reuse, this feature is enabled by default.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// Via the configs method
|
||||
YukiReflection.configs {
|
||||
isEnableMemberCache = true
|
||||
}
|
||||
// Set directly
|
||||
YukiReflection.Configs.isEnableMemberCache = true
|
||||
```
|
||||
|
||||
### Use the configs Method to Configure
|
||||
|
||||
In order to configure multiple features at once, you can directly use the `YukiReflection.configs { ... }` method to configure.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
YukiReflection.configs {
|
||||
debugTag = "YourCustomTag"
|
||||
isDebug = true
|
||||
isAllowPrintingLogs = true
|
||||
isEnableMemberCache = true
|
||||
}
|
||||
```
|
||||
|
||||
::: tip
|
||||
|
||||
For more functions, please refer to [YukiReflection.configs](../api/public/com/highcapable/yukireflection/YukiReflection#configs-method) method, [YukiReflection.Configs](../api/public/com/highcapable/yukireflection/YukiReflection#configs-object).
|
||||
|
||||
:::
|
442
docs-source/src/en/config/api-exception.md
Normal file
@@ -0,0 +1,442 @@
|
||||
---
|
||||
pageClass: hidden-anchor-page
|
||||
---
|
||||
|
||||
# API Exception Handling
|
||||
|
||||
> Exceptions are the main problems often encountered in the development process. Here are some common exceptions that may be encountered during the use of `YukiReflection` and how to deal with them.
|
||||
|
||||
The exception description here will only synchronize the latest API version, and the exception of the older API version will not be described again, please always keep the API version up-to-date.
|
||||
|
||||
## Non-Blocking Exceptions
|
||||
|
||||
> These exceptions will not cause the app to stop running (FC), but will print `E` level logs on the console, and may also stop continuing to execute related functions.
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
Method/Constructor/Field match type "**TYPE**" not allowed
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
A disallowed parameter type was set when looking up methods, constructors, and variables.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// Find a method
|
||||
method {
|
||||
// ❗ Invalid type example is set
|
||||
param(false, 1, 0)
|
||||
// ❗ Invalid type example is set
|
||||
returnType = false
|
||||
}
|
||||
|
||||
// Find a variable
|
||||
field {
|
||||
// ❗ Invalid type example is set
|
||||
type = false
|
||||
}
|
||||
```
|
||||
|
||||
**Solution**
|
||||
|
||||
In the search, `param`, `returnType`, `type` only accept `Class`, `String`, `VariousClass` types, and parameter instances cannot be passed in.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// Find a method
|
||||
method {
|
||||
// ✅ Examples of correct usage
|
||||
param(BooleanType, IntType, IntType)
|
||||
// ✅ Examples of correct usage
|
||||
returnType = BooleanType
|
||||
// ✅ The following scheme is also correct
|
||||
returnType = "java.lang.Boolean"
|
||||
}
|
||||
|
||||
// Find a variable
|
||||
field {
|
||||
// ✅ Examples of correct usage
|
||||
type = BooleanType
|
||||
}
|
||||
```
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
NoSuchMethod/NoSuchConstructor/NoSuchField happend in \[**NAME**\]
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
The target method, constructor, and variable were not found when looking for methods, constructors, and variables.
|
||||
|
||||
**Solution**
|
||||
|
||||
Please confirm that your search criteria can correctly match the specified methods, constructors and variables in the target `Class`.
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
Trying **COUNT** times and all failure by RemedyPlan
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
When using `RemedyPlan` to search for methods, constructors, and variables, the methods, constructors, and variables are still not found.
|
||||
|
||||
**Solution**
|
||||
|
||||
Please confirm the `RemedyPlan` parameter you set and the `Class` that exists in the current app, and try again.
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
You must set a condition when finding a Method/Constructor/Field
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
No conditions are set when looking for methods, constructors, and variables.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
// No conditions are set here
|
||||
}
|
||||
```
|
||||
|
||||
**Solution**
|
||||
|
||||
Please complete your search criteria and try again.
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
Can't find this Class in \[**CLASSLOADER**\]: **CONTENT** Generated by YukiReflection#ReflectionTool
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
The `Class` object to be searched for was not found via `ClassLoader.searchClass`.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
customClassLoader?.searchClass {
|
||||
from(...)
|
||||
// ...
|
||||
}.get()
|
||||
```
|
||||
|
||||
**Solution**
|
||||
|
||||
This is a security exception, please check the conditions you set, use the relevant tools to view the `Class` and bytecode object characteristics in the **Dex** and try again.
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
Can't find this Method/Constructor/Field in \[**CLASS**\]: **CONTENT** Generated by YukiReflection#ReflectionTool
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
The methods, constructors, and variables that need to be found cannot be found by specifying conditions.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
TargetClass.method {
|
||||
name = "test"
|
||||
param(BooleanType)
|
||||
}
|
||||
```
|
||||
|
||||
**Solution**
|
||||
|
||||
This is a security exception, please check the conditions you set, use the relevant tools to view the bytecode object characteristics in the `Class`, and try again.
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
The number of VagueType must be at least less than the count of paramTypes
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
Incorrect use of `VagueType` in `Method`, `Constructor` lookup conditions.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
TargetClass.method {
|
||||
name = "test"
|
||||
// <Scenario 1>
|
||||
param(VagueType)
|
||||
// <Scenario 2>
|
||||
param(VagueType, VagueType ...)
|
||||
}
|
||||
```
|
||||
|
||||
**Solution**
|
||||
|
||||
`VagueType` cannot be completely filled in method and constructor parameters. If there is such a requirement, please use `paramCount`.
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
Field match type class is not found
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
An instance of `Class` for `type` was not found in the lookup criteria set when looking up the variable.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
name = "test"
|
||||
// Assume that the Class of the type set here does not exist
|
||||
type = "com.example.TestClass"
|
||||
}
|
||||
```
|
||||
|
||||
**Solution**
|
||||
|
||||
Please check if `Class` of `type` in the lookup condition exists and try again.
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
Method match returnType class is not found
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
An instance of `Class` of `returnType` was not found in the search criteria set when looking up the method.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
name = "test"
|
||||
// Assume that the Class of returnType set here does not exist
|
||||
returnType = "com.example.TestClass"
|
||||
}
|
||||
```
|
||||
|
||||
**Solution**
|
||||
|
||||
Please check if `Class` of `returnType` in the lookup condition exists and try again.
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
Method/Constructor match paramType\[**INDEX**\] class is not found
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
The `Class` instance subscripted by the `index` number of `param` was not found in the search conditions set when searching for methods and constructors.
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
name = "test"
|
||||
// Assume that the Class with subscript "No.1" set here does not exist
|
||||
param(StringClass, "com.example.TestClass", BooleanType)
|
||||
}
|
||||
```
|
||||
|
||||
**Solution**
|
||||
|
||||
Please check if the `Class` subscripted by the `index` number of `param` in the lookup condition exists and try again.
|
||||
|
||||
## Blocking Exceptions
|
||||
|
||||
> These exceptions will directly cause the app to stop running (FC), at the same time print `E` level logs on the console.
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger NoClassDefFoundError
|
||||
|
||||
Can't find this Class in \[**CLASSLOADER**\]: **CONTENT** Generated by YukiReflection#ReflectionTool
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
The `Class` object you were looking for was not found via `String.toClass(...)` or `classOf<...>()`.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
"com.demo.Test".toClass()
|
||||
```
|
||||
|
||||
**Solution**
|
||||
|
||||
Please check if the `Class` matched by the current string or entity exists in the current `ClassLoader` and try again.
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger IllegalStateException
|
||||
|
||||
ClassLoader \[**CLASSLOADER**\] is not a DexClassLoader
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
Use `ClassLoader.searchClass` to find `Class` but currently `ClassLoader` does not extends `BaseDexClassLoader`.
|
||||
|
||||
**Solution**
|
||||
|
||||
This situation basically does not exist, unless the current app references a Non-ART platform executable (which not realistic) or the current `ClassLoader` is null.
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger IllegalStateException
|
||||
|
||||
VariousClass match failed of those **CLASSES**
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
All `Class` were not found when creating indeterminate `Class` objects using `VariousClass`.
|
||||
|
||||
**Solution**
|
||||
|
||||
After checking whether there is a matching `Class` in the current app and try again.
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger IllegalStateException
|
||||
|
||||
paramTypes is empty, please use emptyParam() instead
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
The empty `param` method is preserved when looking up methods, constructors.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
name = "test"
|
||||
// No parameters are filled in parentheses
|
||||
param()
|
||||
}
|
||||
```
|
||||
|
||||
**Solution**
|
||||
|
||||
To identify this method, the constructor has no parameters, you can have a setter method as follows.
|
||||
|
||||
The first way, set `emptyParam` (recommended)
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
name = "test"
|
||||
emptyParam()
|
||||
}
|
||||
```
|
||||
|
||||
The second way, set `paramCount = 0`
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
name = "test"
|
||||
paramCount = 0
|
||||
}
|
||||
```
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger IllegalStateException
|
||||
|
||||
Cannot create classes cache for "android", please remove "name" param
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
The `DexClassFinder` cache function `searchClass(name = ...)` is used in the System Framework ("android") app.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
searchClass(name = "test") {
|
||||
from(...)
|
||||
// ...
|
||||
}.get()
|
||||
```
|
||||
|
||||
**Solution**
|
||||
|
||||
Since the cache will store the found `Class` name in `SharedPreferences`, but the data directory does not exist in the System Framework, so please do not use this function in the System Framework.
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger IllegalStateException
|
||||
|
||||
Target Class type cannot cast to **TYPE**
|
||||
|
||||
:::
|
||||
|
||||
**Abnormal**
|
||||
|
||||
Wrong type declared when converting string class name to target `Class` using `Class.toClass`, `Class.toClassOrNull`, `GenericClass.argument` methods.
|
||||
|
||||
The following uses the `Class.toClass` method as an example.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// Assume the target type is Activity but it was wrongly cast to WrongClass type
|
||||
val clazz = "android.app.Activity".toClass<WrongClass>()
|
||||
```
|
||||
|
||||
**Solution**
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// <Solution 1> Fill in the correct type
|
||||
val clazz1 = "android.app.Activity".toClass<Activity>()
|
||||
// <Solution 2> Do not fill in the generic declaration
|
||||
val clazz2 = "android.app.Activity".toClass()
|
||||
```
|
||||
|
||||
Please ensure that the generic type declared after executing the method is the specified target `Class` type, and you do not need to fill in the generic declaration if the target type is not sure.
|
56
docs-source/src/en/guide/home.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# Introduce
|
||||
|
||||
> `YukiReflection` is a Reflection API based on the Android platform.
|
||||
|
||||
## Background
|
||||
|
||||
This is a set of simple and efficient Reflection API rebuilt based on `Java` native Reflection API using `Kotlin`.
|
||||
|
||||
`YukiReflection` is also the core functionality that [YukiHookAPI](https://github.com/fankes/YukiHookAPI) is using.
|
||||
|
||||
The name is taken from ["ももくり" heroine Yuki Kurihara](https://www.bilibili.com/bangumi/play/ss5016).
|
||||
|
||||
## Usage
|
||||
|
||||
`YukiReflection` is fully built with `Kotlin` `lambda` syntax.
|
||||
|
||||
It can replace [Java's native Reflection API](https://www.oracle.com/technical-resources/articles/java/javareflection.html) and implement a more complete reflection solution in a more human-friendly language.
|
||||
|
||||
## Language Requirement
|
||||
|
||||
Please use `Kotlin`, the code composition of the API part is also compatible with `Java`, but the implementation of the basic reflection scene **may not be used at all**.
|
||||
|
||||
All Demo sample codes in the document will be described using `Kotlin`, if you don’t know how to use `Kotlin` at all, you may not be able to use `YukiReflection`.
|
||||
|
||||
## Source of Inspiration
|
||||
|
||||
`YukiReflection` was originally the core function integrated in the [YukiHookAPI](https://github.com/fankes/YukiHookAPI) project, and now it is decoupled so that this Reflection API can be used in any Android platform project.
|
||||
|
||||
Now, we only need to write a small amount of code to implement a simple reflection call.
|
||||
|
||||
With `Kotlin` elegant `lambda` and `YukiReflection`, you can make your reflection logic more beautiful and clear.
|
||||
|
||||
> The following example
|
||||
|
||||
:::: code-group
|
||||
::: code-group-item Yuki Reflection
|
||||
|
||||
```kotlin
|
||||
"android.os.SystemProperties".toClass()
|
||||
.method {
|
||||
name = "get"
|
||||
param(StringClass, StringClass)
|
||||
}.get().call("ro.system.build.fingerprint", "none")
|
||||
```
|
||||
|
||||
:::
|
||||
::: code-group-item Java Reflection
|
||||
|
||||
```kotlin
|
||||
Class.forName("android.os.SystemProperties")
|
||||
.getDeclaredMethod("get", String::class.java, String::class.java)
|
||||
.invoke(null, "ro.system.build.fingerprint", "none")
|
||||
```
|
||||
|
||||
:::
|
||||
::::
|
75
docs-source/src/en/guide/quick-start.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# Quick Start
|
||||
|
||||
> Integrate `YukiReflection` into your project.
|
||||
|
||||
## Environment Requirements
|
||||
|
||||
- Windows 7 and above / macOS 10.14 and above / Linux distributions (Arch/Debian)
|
||||
|
||||
- Android Studio 2021.1 and above
|
||||
|
||||
- IntelliJ IDEA 2021.1 and above
|
||||
|
||||
- Kotlin 1.7.0 and above
|
||||
|
||||
- Android Gradle Plugin 7.0 and above
|
||||
|
||||
- Gradle 7.0 and above
|
||||
|
||||
- JVM 11 and above
|
||||
|
||||
## Project Requirements
|
||||
|
||||
The project needs to be created using `Android Studio` or `IntelliJ IDEA` and the type is an Android project and the `Kotlin` environment dependency has been integrated.
|
||||
|
||||
## Integration Dependencies
|
||||
|
||||
**(Optional)** Add dependencies to your project `build.gradle`.
|
||||
|
||||
> The following example
|
||||
|
||||
```groovy
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
// MavenCentral has a 2-hour cache, if you cannot integrate the latest version, please add this address
|
||||
maven { url "https://s01.oss.sonatype.org/content/repositories/releases" }
|
||||
}
|
||||
```
|
||||
|
||||
Add dependencies to your app `build.gradle`.
|
||||
|
||||
> The following example
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
// Base dependencies
|
||||
implementation 'com.highcapable.yukireflection:api:<yuki-version>'
|
||||
}
|
||||
```
|
||||
|
||||
Please change **<yuki-version>** to the latest version from [here](../about/changelog).
|
||||
|
||||
::: danger
|
||||
|
||||
If your project is currently using [YukiHookAPI](https://github.com/fankes/YukiHookAPI), please do not repeatedly integrate **YukiReflection**, because **YukiHookAPI** already contains the functions and exists for related functional changes and repeated integration will cause functional conflicts and cause exceptions.
|
||||
|
||||
At this time, you should go to the [documentation](https://fankes.github.io/YukiHookAPI/en/) of **YukiHookAPI** to view the corresponding tutorial.
|
||||
|
||||
:::
|
||||
|
||||
Modify the `Kotlin` Jvm version to 11 and above in your app `build.gradle`.
|
||||
|
||||
> The following example
|
||||
|
||||
```groovy
|
||||
android {
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '11'
|
||||
}
|
||||
}
|
||||
```
|
13
docs-source/src/en/index.md
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
home: true
|
||||
title: Home
|
||||
heroImage: /images/logo.png
|
||||
actions:
|
||||
- text: Get Started
|
||||
link: /en/guide/home
|
||||
type: primary
|
||||
- text: Changelog
|
||||
link: /en/about/changelog
|
||||
type: secondary
|
||||
footer: MIT License | Copyright (C) 2019-2023 HighCapable
|
||||
---
|
17
docs-source/src/index.md
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
home: true
|
||||
navbar: false
|
||||
sidebar: false
|
||||
title: null
|
||||
heroAlt: null
|
||||
heroText: null
|
||||
tagline: Select a language
|
||||
actions:
|
||||
- text: English
|
||||
link: /en/
|
||||
type: secondary
|
||||
- text: 简体中文
|
||||
link: /zh-cn/
|
||||
type: secondary
|
||||
footer: MIT License | Copyright (C) 2019-2023 HighCapable
|
||||
---
|
33
docs-source/src/zh-cn/about/about.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# 关于此文档
|
||||
|
||||
> 此文档由 [VuePress](https://v2.vuepress.vuejs.org/zh) 强力驱动。
|
||||
|
||||
## License
|
||||
|
||||
[The MIT License (MIT)](https://github.com/fankes/YukiReflection/blob/master/LICENSE)
|
||||
|
||||
```:no-line-numbers
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2019-2023 HighCapable
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
版权所有 © 2019-2023 HighCapable
|
13
docs-source/src/zh-cn/about/changelog.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# 更新日志
|
||||
|
||||
> 这里记录了 `YukiReflection` 的版本更新历史。
|
||||
|
||||
::: danger
|
||||
|
||||
我们只会对最新的 API 版本进行维护,若你正在使用过时的 API 版本则代表你自愿放弃一切维护的可能性。
|
||||
|
||||
:::
|
||||
|
||||
### 1.0.0 | 2023.01.26  <Badge type="tip" text="最新" vertical="middle" />
|
||||
|
||||
- 首个版本提交至 Maven
|
11
docs-source/src/zh-cn/about/contacts.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# 联系我们
|
||||
|
||||
> 如在使用中有任何问题,或有任何建设性的建议,都可以联系我们。
|
||||
|
||||
加入我们 [点击加入 Telegram 群组](https://t.me/YukiReflection)
|
||||
|
||||
在 **酷安** 找到我 [@星夜不荟](http://www.coolapk.com/u/876977)
|
||||
|
||||
## 助力维护
|
||||
|
||||
感谢您选择并使用 `YukiReflection`,如有代码相关的建议和请求,可在 Github 提交 Pull Request。
|
104
docs-source/src/zh-cn/about/future.md
Normal file
@@ -0,0 +1,104 @@
|
||||
# 展望未来
|
||||
|
||||
> 未来是美好的,也是不确定的,让我们共同期待 `YukiReflection` 在未来的发展空间。
|
||||
|
||||
## 未来的计划
|
||||
|
||||
> 这里收录了 `YukiReflection` 可能会在后期添加的功能。
|
||||
|
||||
### 自动生成反射代码
|
||||
|
||||
使用 `stub` 的方式创建一个 `Kotlin` 类,并声明其中的参数,以及其在各个版本中的不同状态。
|
||||
|
||||
比如下面的这个 `Java` 类就是我们需要反射的目标类。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```java:no-line-numbers
|
||||
package com.example.test;
|
||||
|
||||
public class MyClass {
|
||||
|
||||
private String myField = "test";
|
||||
|
||||
public MyClass() {
|
||||
// ...
|
||||
}
|
||||
|
||||
private String myMethod1(String var1, int var2) {
|
||||
// ...
|
||||
}
|
||||
|
||||
private void myMethod2() {
|
||||
// ...
|
||||
}
|
||||
|
||||
private void myMethod3(String var1) {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
通过目前 API 的现有用法可以使用如下方式反射调用这个类。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
classOf<MyClass>().buildOf().current {
|
||||
// 调用 myField
|
||||
val value = field { name = "myField" }.string()
|
||||
// 调用 myMethod1
|
||||
val methodValue = method { name = "myMethod1" }.string("test", 0)
|
||||
// 调用 myMethod2
|
||||
method { name = "myMethod2" }.call()
|
||||
// 调用 myMethod3
|
||||
method { name = "myMethod3" }.call("test")
|
||||
}
|
||||
```
|
||||
|
||||
目前要实现的功能是可以使用反射功能直接定义为如下 `Kotlin` 类。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
package com.example.test
|
||||
|
||||
@ReflectClass
|
||||
class MyClass {
|
||||
|
||||
@ReflectField
|
||||
val myField: String = fieldValueOf("none")
|
||||
|
||||
@ReflectMethod
|
||||
fun myMethod1(var1: String, var2: Int): String = methodReturnValueOf("none")
|
||||
|
||||
@ReflectMethod
|
||||
fun myMethod2() = MethodReturnType.Unit
|
||||
|
||||
@ReflectMethod
|
||||
fun myMethod3(var1: String) = MethodReturnType.Unit
|
||||
}
|
||||
```
|
||||
|
||||
然后我们就可以直接调用这个定义好的 `Kotlin` 类来实现反射功能,API 会根据注解自动生成反射代码。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
MyClass().also {
|
||||
// 调用 myField
|
||||
val value = it.myField
|
||||
// 调用 myMethod1
|
||||
val methodValue = it.myMethod1("test", 0)
|
||||
// 调用 myMethod2
|
||||
it.myMethod2()
|
||||
// 调用 myMethod3
|
||||
it.myMethod3("test")
|
||||
}
|
||||
```
|
||||
|
||||
::: tip
|
||||
|
||||
以上功能可能会在实际推出后有所变化,最终以实际版本的功能为准。
|
||||
|
||||
:::
|
1698
docs-source/src/zh-cn/api/features.md
Normal file
55
docs-source/src/zh-cn/api/home.md
Normal file
@@ -0,0 +1,55 @@
|
||||
---
|
||||
next:
|
||||
text: Public API
|
||||
link: /zh-cn/api/public/com/highcapable/yukireflection/YukiReflection
|
||||
---
|
||||
|
||||
# 文档介绍
|
||||
|
||||
> 这里的文档将同步最新 API 版本的相关用法,请保持 `YukiReflection` 为最新版本以使用最新版本的功能。
|
||||
|
||||
## 功能描述说明
|
||||
|
||||
> 功能描述主要介绍当前 API 的相关用法和用途。
|
||||
|
||||
## 功能示例说明
|
||||
|
||||
> 功能示例主要展示了当前 API 的基本用法示例,可供参考。
|
||||
|
||||
## 变更记录说明
|
||||
|
||||
首个版本的功能将标记为 `v<version>` `添加`;
|
||||
|
||||
后期新增加的功能将标记为 `v<version>` `新增`;
|
||||
|
||||
后期修改的功能将被追加为 `v<version>` `修改`;
|
||||
|
||||
后期被作废的功能将标记为 `v<version>` `作废` 并会标注删除线;
|
||||
|
||||
后期被删除的功能将标记为 `v<version>` `移除` 并会标注删除线。
|
||||
|
||||
## 相关符号说明
|
||||
|
||||
- *kt* Kotlin Static File
|
||||
|
||||
- *annotation* 注解
|
||||
|
||||
- *interface* 接口
|
||||
|
||||
- *object* 类 (单例)
|
||||
|
||||
- *class* 类
|
||||
|
||||
- *field* 变量或 `get`、`set` 方法或只读的 `get` 方法
|
||||
|
||||
- *method* 方法
|
||||
|
||||
- *enum* Enum 常量
|
||||
|
||||
- *ext-field* 扩展的变量 (全局)
|
||||
|
||||
- *ext-method* 扩展的方法 (全局)
|
||||
|
||||
- *i-ext-field* 扩展的变量 (调用域限制)
|
||||
|
||||
- *i-ext-method* 扩展的方法 (调用域限制)
|
@@ -0,0 +1,155 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# YukiReflection <span class="symbol">- object</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
object YukiReflection
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 这是 `YukiReflection` 的装载调用类。
|
||||
|
||||
## API_VERSION_NAME <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
const val API_VERSION_NAME: String
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获取当前 `YukiReflection` 的版本。
|
||||
|
||||
## API_VERSION_CODE <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
const val API_VERSION_CODE: Int
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获取当前 `YukiReflection` 的版本号。
|
||||
|
||||
## Configs <span class="symbol">- object</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
object Configs
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 对 API 相关功能的配置类。
|
||||
|
||||
### debugTag <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var debugTag: String
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 这是一个调试日志的全局标识。
|
||||
|
||||
默认文案为 `YukiReflection`。
|
||||
|
||||
你可以修改为你自己的文案。
|
||||
|
||||
### isDebug <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var isDebug: Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 是否启用 Debug 模式。
|
||||
|
||||
默认不启用,启用后将交由日志输出管理器打印详细日志 (例如反射查找功能的耗时) 到控制台。
|
||||
|
||||
请过滤 `debugTag` 即可找到每条日志。
|
||||
|
||||
### isAllowPrintingLogs <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var isAllowPrintingLogs: Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 是否启用调试日志的输出功能。
|
||||
|
||||
::: warning
|
||||
|
||||
关闭后将会停用 **YukiReflection** 对全部日志的输出。
|
||||
|
||||
:::
|
||||
|
||||
### isEnableMemberCache <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var isEnableMemberCache: Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 是否启用 `Member` 缓存功能。
|
||||
|
||||
为防止 `Member` 复用过高造成的系统 GC 问题,此功能默认启用。
|
||||
|
||||
启用后会缓存已经找到的 `Method`、`Constructor`、`Field`。
|
||||
|
||||
缓存的 `Member` 都将处于 `ReflectsCacheStore` 的全局静态实例中。
|
||||
|
||||
推荐使用 `MethodFinder`、`ConstructorFinder`、`FieldFinder` 来获取 `Member`。
|
||||
|
||||
除非缓存的 `Member` 发生了混淆的问题,例如使用 R8 混淆后的 APP 的目标 `Member`,否则建议启用。
|
||||
|
||||
## configs <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun configs(initiate: Configs.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 对 `Configs` 类实现了一个 `lambda` 方法体。
|
||||
|
||||
你可以轻松地调用它进行配置。
|
@@ -0,0 +1,221 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# CurrentClass <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class CurrentClass internal constructor(internal val classSet: Class<*>, internal val instance: Any)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当前实例的类操作对象。
|
||||
|
||||
## name <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val name: String
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得当前 `classSet` 的 `Class.getName`。
|
||||
|
||||
## simpleName <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val simpleName: String
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得当前 `classSet` 的 `Class.getSimpleName`。
|
||||
|
||||
## generic <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun generic(): GenericClass?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得当前实例中的泛型父类。
|
||||
|
||||
如果当前实例不存在泛型将返回 `null`。
|
||||
|
||||
## generic <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun generic(initiate: GenericClass.() -> Unit): GenericClass?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得当前实例中的泛型父类。
|
||||
|
||||
如果当前实例不存在泛型将返回 `null`。
|
||||
|
||||
## superClass <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun superClass(): SuperClass
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 调用父类实例。
|
||||
|
||||
## field <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun field(initiate: FieldConditions): FieldFinder.Result.Instance
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 调用当前实例中的变量。
|
||||
|
||||
## method <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun method(initiate: MethodConditions): MethodFinder.Result.Instance
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 调用当前实例中的方法。
|
||||
|
||||
## SuperClass <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class SuperClass internal constructor(internal val superClassSet: Class<*>)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当前类的父类实例的类操作对象。
|
||||
|
||||
### name <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val name: String
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得当前 `classSet` 中父类的 `Class.getName`。
|
||||
|
||||
### simpleName <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val simpleName: String
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得当前 `classSet` 中父类的 `Class.getSimpleName`。
|
||||
|
||||
### generic <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun generic(): GenericClass?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得当前实例父类中的泛型父类。
|
||||
|
||||
如果当前实例不存在泛型将返回 `null`。
|
||||
|
||||
### generic <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun generic(initiate: GenericClass.() -> Unit): GenericClass?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得当前实例父类中的泛型父类。
|
||||
|
||||
如果当前实例不存在泛型将返回 `null`。
|
||||
|
||||
### field <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun field(initiate: FieldConditions): FieldFinder.Result.Instance
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 调用父类实例中的变量。
|
||||
|
||||
### method <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun method(initiate: MethodConditions): MethodFinder.Result.Instance
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 调用父类实例中的方法。
|
@@ -0,0 +1,35 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# GenericClass <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class GenericClass internal constructor(private val type: ParameterizedType)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当前 `Class` 的泛型父类操作对象。
|
||||
|
||||
## argument <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun argument(index: Int): Class<*>
|
||||
```
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> argument(index: Int): Class<T>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得泛型参数数组下标的 `Class` 实例。
|
@@ -0,0 +1,51 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# VariousClass <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class VariousClass(private vararg val name: String)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 这是一个不确定性 `Class` 类名装载器,通过 `name` 装载 `Class` 名称数组。
|
||||
|
||||
## get <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun get(loader: ClassLoader? = null, initialize: Boolean): Class<*>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获取匹配的实体类。
|
||||
|
||||
使用当前 `loader` 装载目标 `Class`。
|
||||
|
||||
## getOrNull <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun getOrNull(loader: ClassLoader? = null, initialize: Boolean): Class<*>?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获取匹配的实体类。
|
||||
|
||||
使用当前 `loader` 装载目标 `Class`。
|
||||
|
||||
匹配不到 `Class` 会返回 `null`,不会抛出异常。
|
@@ -0,0 +1,630 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# ReflectionFactory <span class="symbol">- kt</span>
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 这是自定义 `Member` 和 `Class` 相关功能的查找匹配以及 `invoke` 的封装类。
|
||||
|
||||
## ClassLoader.listOfClasses <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun ClassLoader.listOfClasses(): List<String>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 写出当前 `ClassLoader` 下所有 `Class` 名称数组。
|
||||
|
||||
::: warning
|
||||
|
||||
此方法在 **Class** 数量过多时会非常耗时。
|
||||
|
||||
若要按指定规则查找一个 **Class**,请使用 [ClassLoader.searchClass](#classloader-searchclass-ext-method) 方法。
|
||||
|
||||
:::
|
||||
|
||||
## ClassLoader.searchClass <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun ClassLoader.searchClass(context: Context?, name: String, async: Boolean, initiate: ClassConditions): DexClassFinder.Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 通过当前 `ClassLoader` 按指定条件查找并得到 **Dex** 中的 `Class`。
|
||||
|
||||
::: danger
|
||||
|
||||
此方法在 **Class** 数量过多及查找条件复杂时会非常耗时。
|
||||
|
||||
建议启用 **async** 或设置 **name** 参数,**name** 参数将在当前 APP 不同版本中自动进行本地缓存以提升效率。
|
||||
|
||||
如果使用了 **async** 或 **name** 参数,则必须填写 **context** 参数。
|
||||
|
||||
此功能尚在试验阶段,性能与稳定性可能仍然存在问题,使用过程遇到问题请向我们报告并帮助我们改进。
|
||||
|
||||
:::
|
||||
|
||||
## Class.hasExtends <span class="symbol">- ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val Class<*>.hasExtends: Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当前 `Class` 是否有继承关系,父类是 `Any` 将被认为没有继承关系。
|
||||
|
||||
## Class?.extends <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
infix fun Class<*>?.extends(other: Class<*>?): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当前 `Class` 是否继承于 `other`。
|
||||
|
||||
如果当前 `Class` 就是 `other` 也会返回 `true`。
|
||||
|
||||
如果当前 `Class` 为 `null` 或 `other` 为 `null` 会返回 `false`。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以使用此方法来判断两个 `Class` 是否存在继承关系。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 假设下面这两个 Class 就是你需要判断的 Class
|
||||
val classA: Class<*>?
|
||||
val classB: Class<*>?
|
||||
// 判断 A 是否继承于 B
|
||||
if (classA extends classB) {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
## Class?.notExtends <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
infix fun Class<*>?.notExtends(other: Class<*>?): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当前 `Class` 是否不继承于 `other`。
|
||||
|
||||
此方法相当于 `extends` 的反向判断。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以使用此方法来判断两个 `Class` 是否不存在继承关系。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 假设下面这两个 Class 就是你需要判断的 Class
|
||||
val classA: Class<*>?
|
||||
val classB: Class<*>?
|
||||
// 判断 A 是否不继承于 B
|
||||
if (classA notExtends classB) {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
## Class?.implements <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
infix fun Class<*>?.implements(other: Class<*>?): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当前 `Class` 是否实现了 `other` 接口类。
|
||||
|
||||
如果当前 `Class` 为 `null` 或 `other` 为 `null` 会返回 `false`。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以使用此方法来判断两个 `Class` 是否存在依赖关系。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 假设下面这两个 Class 就是你需要判断的 Class
|
||||
val classA: Class<*>?
|
||||
val classB: Class<*>?
|
||||
// 判断 A 是否实现了 B 接口类
|
||||
if (classA implements classB) {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
## Class?.notImplements <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
infix fun Class<*>?.notImplements(other: Class<*>?): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当前 `Class` 是否未实现 `other` 接口类。
|
||||
|
||||
此方法相当于 `implements` 的反向判断。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以使用此方法来判断两个 `Class` 是否不存在依赖关系。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 假设下面这两个 Class 就是你需要判断的 Class
|
||||
val classA: Class<*>?
|
||||
val classB: Class<*>?
|
||||
// 判断 A 是否未实现 B 接口类
|
||||
if (classA notImplements classB) {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
## Class.toJavaPrimitiveType <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun Class<*>.toJavaPrimitiveType(): Class<*>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 自动转换当前 `Class` 为 Java 原始类型 (Primitive Type)。
|
||||
|
||||
如果当前 `Class` 为 Java 或 Kotlin 基本类型将自动执行类型转换。
|
||||
|
||||
当前能够自动转换的基本类型如下。
|
||||
|
||||
- `kotlin.Unit`
|
||||
- `java.lang.Void`
|
||||
- `java.lang.Boolean`
|
||||
- `java.lang.Integer`
|
||||
- `java.lang.Float`
|
||||
- `java.lang.Double`
|
||||
- `java.lang.Long`
|
||||
- `java.lang.Short`
|
||||
- `java.lang.Character`
|
||||
- `java.lang.Byte`
|
||||
|
||||
## String.toClass <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.toClass(loader: ClassLoader?, initialize: Boolean): Class<*>
|
||||
```
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> String.toClass(loader: ClassLoader?, initialize: Boolean): Class<T>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 通过字符串类名转换为 `loader` 中的实体类。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以直接填写你要查找的目标 `Class`,必须在默认 `ClassLoader` 下存在。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
"com.example.demo.DemoClass".toClass()
|
||||
```
|
||||
|
||||
你还可以自定义 `Class` 所在的 `ClassLoader`。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
val customClassLoader: ClassLoader? = ... // 假设这个就是你的 ClassLoader
|
||||
"com.example.demo.DemoClass".toClass(customClassLoader)
|
||||
```
|
||||
|
||||
你还可以指定 `Class` 的目标类型。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 指定的 DemoClass 必须存在或为可访问的 stub
|
||||
"com.example.demo.DemoClass".toClass<DemoClass>()
|
||||
```
|
||||
|
||||
你还可以设置在获取到这个 `Class` 时是否自动执行其默认的静态方法块,默认情况下不会执行。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 获取并执行 DemoClass 默认的静态方法块
|
||||
"com.example.demo.DemoClass".toClass(initialize = true)
|
||||
```
|
||||
|
||||
默认的静态方法块在 Java 中使用如下方式定义。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```java:no-line-numbers
|
||||
public class DemoClass {
|
||||
|
||||
static {
|
||||
// 这里是静态方法块的内容
|
||||
}
|
||||
|
||||
public DemoClass() {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## String.toClassOrNull <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.toClassOrNull(loader: ClassLoader?, initialize: Boolean): Class<*>?
|
||||
```
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> String.toClassOrNull(loader: ClassLoader?, initialize: Boolean): Class<T>?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 通过字符串类名转换为 `loader` 中的实体类。
|
||||
|
||||
找不到 `Class` 会返回 `null`,不会抛出异常。
|
||||
|
||||
**功能示例**
|
||||
|
||||
用法请参考 [String.toClass](#string-toclass-ext-method) 方法。
|
||||
|
||||
## classOf <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> classOf(loader: ClassLoader?, initialize: Boolean): Class<T>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 通过 `T` 得到其 `Class` 实例并转换为实体类。
|
||||
|
||||
**功能示例**
|
||||
|
||||
我们要获取一个 `Class` 在 `Kotlin` 下不通过反射时应该这样做。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
DemoClass::class.java
|
||||
```
|
||||
|
||||
现在,你可以直接 `cast` 一个实例并获取它的 `Class` 对象,必须在当前 `ClassLoader` 下存在。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
classOf<DemoClass>()
|
||||
```
|
||||
|
||||
若目标存在的 `Class` 为 `stub`,通过这种方式,你还可以自定义 `Class` 所在的 `ClassLoader`。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
val customClassLoader: ClassLoader? = ... // 假设这个就是你的 ClassLoader
|
||||
classOf<DemoClass>(customClassLoader)
|
||||
```
|
||||
|
||||
## String.hasClass <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.hasClass(loader: ClassLoader?): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 通过字符串类名使用指定的 `ClassLoader` 查找是否存在。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以轻松的使用此方法判断字符串中的类是否存在,效果等同于直接使用 `Class.forName`。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
if("com.example.demo.DemoClass".hasClass()) {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
填入方法中的 `loader` 参数可判断指定的 `ClassLoader` 中的 `Class` 是否存在。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
val customClassLoader: ClassLoader? = ... // 假设这个就是你的 ClassLoader
|
||||
if("com.example.demo.DemoClass".hasClass(customClassLoader)) {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
## Class.hasField <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.hasField(initiate: FieldConditions): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 查找变量是否存在。
|
||||
|
||||
## Class.hasMethod <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.hasMethod(initiate: MethodConditions): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 查找方法是否存在。
|
||||
|
||||
## Class.hasConstructor <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.hasConstructor(initiate: ConstructorConditions): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 查找构造方法是否存在。
|
||||
|
||||
## Member.hasModifiers <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Member.hasModifiers(conditions: ModifierConditions): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 查找 `Member` 中匹配的描述符。
|
||||
|
||||
## Class.hasModifiers <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.hasModifiers(conditions: ModifierConditions): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 查找 `Class` 中匹配的描述符。
|
||||
|
||||
## Class.field <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.field(initiate: FieldConditions): FieldFinder.Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 查找并得到变量。
|
||||
|
||||
## Class.method <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.method(initiate: MethodConditions): MethodFinder.Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 查找并得到方法。
|
||||
|
||||
## Class.constructor <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.constructor(initiate: ConstructorConditions): ConstructorFinder.Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 查找并得到构造方法。
|
||||
|
||||
## Class.generic <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun Class<*>.generic(): GenericClass?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得当前 `Class` 的泛型父类。
|
||||
|
||||
如果当前实例不存在泛型将返回 `null`。
|
||||
|
||||
## Class.generic <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.generic(initiate: GenericClass.() -> Unit): GenericClass?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得当前 `Class` 的泛型父类。
|
||||
|
||||
如果当前实例不存在泛型将返回 `null`。
|
||||
|
||||
## Any.current <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T : Any> T.current(ignored: Boolean): CurrentClass
|
||||
```
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T : Any> T.current(ignored: Boolean, initiate: CurrentClass.() -> Unit): T
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得当前实例的类操作对象。
|
||||
|
||||
## Class.buildOf <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.buildOf(vararg args: Any?, initiate: ConstructorConditions): Any?
|
||||
```
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <T> Class<*>.buildOf(vararg args: Any?, initiate: ConstructorConditions): T?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 通过构造方法创建新实例,指定类型 `T` 或任意类型 `Any`。
|
||||
|
||||
## Class.allMethods <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.allMethods(isAccessible: Boolean, result: (index: Int, method: Method) -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 遍历当前类中的所有方法。
|
||||
|
||||
## Class.allConstructors <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.allConstructors(isAccessible: Boolean, result: (index: Int, constructor: Constructor<*>) -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 遍历当前类中的所有构造方法。
|
||||
|
||||
## Class.allFields <span class="symbol">- ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun Class<*>.allFields(isAccessible: Boolean, result: (index: Int, field: Field) -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 遍历当前类中的所有变量。
|