mirror of
https://github.com/HighCapable/YukiReflection.git
synced 2025-09-08 03:24:18 +08:00
Initial commit
This commit is contained in:
60
docs-source/src/.vuepress/config.ts
Normal file
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
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
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
BIN
docs-source/src/.vuepress/public/images/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
179
docs-source/src/.vuepress/styles/index.scss
Normal file
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
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
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
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
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
1757
docs-source/src/en/api/features.md
Normal file
File diff suppressed because it is too large
Load Diff
55
docs-source/src/en/api/home.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
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
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
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
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
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
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
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
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
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
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
1698
docs-source/src/zh-cn/api/features.md
Normal file
File diff suppressed because it is too large
Load Diff
55
docs-source/src/zh-cn/api/home.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` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 遍历当前类中的所有变量。
|
@@ -0,0 +1,119 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# BaseFinder <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
abstract class BaseFinder
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 这是 `Class` 与 `Member` 查找类功能的基本类实现。
|
||||
|
||||
## BaseFinder.IndexTypeCondition <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class IndexTypeCondition internal constructor(private val type: IndexConfigType)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 字节码下标筛选实现类。
|
||||
|
||||
### index <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun index(num: Int)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置下标。
|
||||
|
||||
若 `index` 小于零则为倒序,此时可以使用 `IndexTypeConditionSort.reverse` 方法实现。
|
||||
|
||||
可使用 `IndexTypeConditionSort.first` 和 `IndexTypeConditionSort.last` 设置首位和末位筛选条件。
|
||||
|
||||
### index <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun index(): IndexTypeConditionSort
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到下标。
|
||||
|
||||
### IndexTypeConditionSort <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class IndexTypeConditionSort internal constructor()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 字节码下标排序实现类。
|
||||
|
||||
#### first <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun first()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置满足条件的第一个。
|
||||
|
||||
#### last <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun last()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置满足条件的最后一个。
|
||||
|
||||
#### reverse <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun reverse(num: Int)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置倒序下标。
|
@@ -0,0 +1,75 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# CountRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class CountRules private constructor()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 这是一个模糊 `Class`、`Member` 数组 (下标) 个数条件实现类。
|
||||
|
||||
可对 R8 混淆后的 `Class`、`Member` 进行更加详细的定位。
|
||||
|
||||
## Int.isZero <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun Int.isZero(): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 是否为 0。
|
||||
|
||||
## Int.moreThan <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun Int.moreThan(count: Int): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 大于 `count`。
|
||||
|
||||
## Int.lessThan <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun Int.lessThan(count: Int): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 小于 `count`。
|
||||
|
||||
## Int.inInterval <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun Int.inInterval(countRange: IntRange): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 在 `countRange` 区间 A ≤ this ≤ B。
|
@@ -0,0 +1,205 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# ModifierRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class ModifierRules private constructor()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 这是一个 `Class`、`Member` 描述符条件实现类。
|
||||
|
||||
可对 R8 混淆后的 `Class`、`Member` 进行更加详细的定位。
|
||||
|
||||
## isPublic <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isPublic: Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Class`、`Member` 类型是否包含 `public`。
|
||||
|
||||
## isPrivate <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isPrivate: Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Class`、`Member` 类型是否包含 `private`。
|
||||
|
||||
## isProtected <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isProtected: Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Class`、`Member` 类型是否包含 `protected`。
|
||||
|
||||
## isStatic <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isStatic: Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Class`、`Member` 类型是否包含 `static`。
|
||||
|
||||
对于任意的静态 `Class`、`Member` 可添加此描述进行确定。
|
||||
|
||||
::: warning
|
||||
|
||||
Kotlin → Jvm 后的 **object** 类中的方法并不是静态的。
|
||||
|
||||
:::
|
||||
|
||||
## isFinal <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isFinal: Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Class`、`Member` 类型是否包含 `synchronized`。
|
||||
|
||||
## isVolatile <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isVolatile: Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Field` 类型是否包含 `volatile`。
|
||||
|
||||
## isTransient <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isTransient: Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Field` 类型是否包含 `transient`。
|
||||
|
||||
## isNative <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isNative: Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Method` 类型是否包含 `native`。
|
||||
|
||||
对于任意 JNI 对接的 `Method` 可添加此描述进行确定。
|
||||
|
||||
## isInterface <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isInterface: Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Class` 类型是否包含 `interface`。
|
||||
|
||||
## isAbstract <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isAbstract: Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Class`、`Member` 类型是否包含 `abstract`。
|
||||
|
||||
对于任意的抽象 `Class`、`Member` 可添加此描述进行确定。
|
||||
|
||||
## isStrict <span class="symbol">- i-ext-field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val isStrict: Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Class`、`Member` 类型是否包含 `strictfp`。
|
@@ -0,0 +1,121 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# NameRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class NameRules private constructor()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 这是一个模糊 `Class`、`Member` 名称条件实现类。
|
||||
|
||||
可对 R8 混淆后的 `Class`、`Member` 进行更加详细的定位。
|
||||
|
||||
## String.isSynthetic <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.isSynthetic(index: Int): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 是否为匿名类的主类调用对象。
|
||||
|
||||
## String.isOnlySymbols <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.isOnlySymbols(): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 是否只有符号。
|
||||
|
||||
## String.isOnlyLetters <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.isOnlyLetters(): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 是否只有字母。
|
||||
|
||||
## String.isOnlyNumbers <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.isOnlyNumbers(): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 是否只有数字。
|
||||
|
||||
## String.isOnlyLettersNumbers <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.isOnlyLettersNumbers(): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 是否只有字母或数字。
|
||||
|
||||
## String.isOnlyLowercase <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.isOnlyLowercase(): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 是否只有小写字母。
|
||||
|
||||
在没有其它条件的情况下设置此条件允许判断对象存在字母以外的字符。
|
||||
|
||||
## String.isOnlyUppercase <span class="symbol">- i-ext-method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun String.isOnlyUppercase(): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 是否只有大写字母。
|
||||
|
||||
在没有其它条件的情况下设置此条件允许判断对象存在字母以外的字符。
|
@@ -0,0 +1,19 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# ObjectRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class ObjectRules private constructor(private val instance: Any)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 这是一个任意对象条件实现类。
|
||||
|
||||
可对 R8 混淆后的 `Class`、`Member` 进行更加详细的定位。
|
@@ -0,0 +1,726 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# 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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Class` 查找类。
|
||||
|
||||
可使用 `BaseDexClassLoader` 通过指定条件查找指定 `Class` 或一组 `Class`。
|
||||
|
||||
::: warning
|
||||
|
||||
此功能尚在试验阶段,性能与稳定性可能仍然存在问题,使用过程遇到问题请向我们报告并帮助我们改进。
|
||||
|
||||
:::
|
||||
|
||||
## companion object <span class="symbol">- object</span>
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
### clearCache <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun clearCache(context: Context, versionName: String?, versionCode: Long?)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 清除当前 `DexClassFinder` 的 `Class` 缓存。
|
||||
|
||||
适用于全部通过 [ClassLoader.searchClass](../../../factory/ReflectionFactory#classloader-searchclass-ext-method) 获取的 `DexClassFinder`。
|
||||
|
||||
## fullName <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var fullName: String
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 完整名称。
|
||||
|
||||
只会查找匹配到的 `Class.getName`。
|
||||
|
||||
例如 `com.demo.Test` 需要填写 `com.demo.Test`。
|
||||
|
||||
## simpleName <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var simpleName: String
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置在指定包名范围查找当前 `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)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件。
|
||||
|
||||
## fullName <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun fullName(value: String): ClassNameRules
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 完整名称。
|
||||
|
||||
只会查找匹配到的 `Class.getName`。
|
||||
|
||||
例如 `com.demo.Test` 需要填写 `com.demo.Test`。
|
||||
|
||||
## simpleName <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun simpleName(value: String): ClassNameRules
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `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)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 完整名称条件。
|
||||
|
||||
只会查找匹配到的 `Class.getName`。
|
||||
|
||||
## simpleName <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun simpleName(conditions: NameConditions)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 简单名称条件。
|
||||
|
||||
只会查找匹配到的 `Class.getSimpleName`。
|
||||
|
||||
## singleName <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun singleName(conditions: NameConditions)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 独立名称条件。
|
||||
|
||||
设置后将首先使用 `Class.getSimpleName`,若为空则会使用 `Class.getName` 进行处理。
|
||||
|
||||
## extends <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> extends()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 继承的父类。
|
||||
|
||||
## extends <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun extends(vararg name: String)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 继承的父类。
|
||||
|
||||
会同时查找 `name` 中所有匹配的父类。
|
||||
|
||||
## implements <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> implements()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 实现的接口类。
|
||||
|
||||
## implements <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun implements(vararg name: String)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 实现的接口类。
|
||||
|
||||
会同时查找 `name` 中所有匹配的接口类。
|
||||
|
||||
## anonymous <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun anonymous()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 标识 `Class` 为匿名类。
|
||||
|
||||
例如 `com.demo.Test$1` 或 `com.demo.Test$InnerTest`。
|
||||
|
||||
标识后你可以使用 [enclosing](#enclosing-method) 来进一步指定匿名类的 (封闭类) 主类。
|
||||
|
||||
## noExtends <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun noExtends()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 没有任何继承。
|
||||
|
||||
此时 `Class` 只应该继承于 `Any`。
|
||||
|
||||
::: warning
|
||||
|
||||
设置此条件后 [extends](#extends-method) 将失效。
|
||||
|
||||
:::
|
||||
|
||||
## noImplements <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun noImplements()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 没有任何接口。
|
||||
|
||||
::: warning
|
||||
|
||||
设置此条件后 [implements](#implements-method) 将失效。
|
||||
|
||||
:::
|
||||
|
||||
## noSuper <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun noSuper()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `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()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 匿名类的 (封闭类) 主类。
|
||||
|
||||
## enclosing <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun enclosing(vararg name: String)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 匿名类的 (封闭类) 主类。
|
||||
|
||||
会同时查找 `name` 中所有匹配的 (封闭类) 主类。
|
||||
|
||||
## FromPackageRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class FromPackageRules internal constructor(private val packages: ArrayList<ClassRulesData.PackageRulesData>)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 包名范围名称过滤匹配条件实现类。
|
||||
|
||||
### absolute <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun absolute()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置包名绝对匹配。
|
||||
|
||||
例如有如下包名 ↓
|
||||
|
||||
`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)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 类名匹配条件实现类。
|
||||
|
||||
### optional <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun optional()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置类名可选。
|
||||
|
||||
例如有如下类名 ↓
|
||||
|
||||
`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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 满足的 `Member` 条件。
|
||||
|
||||
## field <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun field(initiate: FieldRules.() -> Unit): MemberRulesResult
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 满足的 `Field` 条件。
|
||||
|
||||
## method <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun method(initiate: MethodRules.() -> Unit): MemberRulesResult
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Class` 满足的 `Method` 条件。
|
||||
|
||||
## constructor <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun constructor(initiate: ConstructorRules.() -> Unit): MemberRulesResult
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Class` 查找结果实现类。
|
||||
|
||||
### result <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun result(initiate: Result.() -> Unit): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建监听结果事件方法体。
|
||||
|
||||
### get <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun get(): Class<*>?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Class` 本身。
|
||||
|
||||
若有多个 `Class` 结果只会返回第一个。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回 `null`。
|
||||
|
||||
若你设置了 `async` 请使用 [wait](#wait-method) 方法。
|
||||
|
||||
### all <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun all(): HashSet<Class<*>>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Class` 本身数组。
|
||||
|
||||
返回全部查找条件匹配的多个 `Class` 实例。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回空的 `HashSet`。
|
||||
|
||||
若你设置了 `async` 请使用 [waitAll](#waitall-method) 方法。
|
||||
|
||||
### all <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun all(result: (Class<*>) -> Unit): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Class` 本身数组 (依次遍历)。
|
||||
|
||||
回调全部查找条件匹配的多个 `Class` 实例。
|
||||
|
||||
在查找条件找不到任何结果的时候将不会执行。
|
||||
|
||||
若你设置了 `async` 请使用 [waitAll](#waitall-method) 方法。
|
||||
|
||||
### wait <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun wait(result: (Class<*>?) -> Unit): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Class` 本身 (异步)。
|
||||
|
||||
若有多个 `Class` 结果只会回调第一个。
|
||||
|
||||
在查找条件找不到任何结果的时候将回调 null。
|
||||
|
||||
你需要设置 `async` 后此方法才会被回调,否则请使用 [get](#get-method) 方法。
|
||||
|
||||
### waitAll <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun waitAll(result: (HashSet<Class<*>>) -> Unit): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Class` 本身数组 (异步)。
|
||||
|
||||
回调全部查找条件匹配的多个 `Class` 实例。
|
||||
|
||||
在查找条件找不到任何结果的时候将回调空的 `HashSet`。
|
||||
|
||||
你需要设置 `async` 后此方法才会被回调,否则请使用 [all](#all-method) 方法。
|
||||
|
||||
### onNoClassDefFoundError <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun onNoClassDefFoundError(result: (Throwable) -> Unit): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 监听找不到 `Class` 时。
|
||||
|
||||
### ignored <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun ignored(): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 忽略异常并停止打印任何错误日志。
|
||||
|
||||
此时若要监听异常结果,你需要手动实现 [onNoClassDefFoundError](#onnoclassdeffounderror-method) 方法。
|
@@ -0,0 +1,145 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# ConstructorRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class ConstructorRules internal constructor(internal val rulesData: ConstructorRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Constructor` 查找条件实现类。
|
||||
|
||||
## paramCount <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var paramCount: Int
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Constructor` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此变量指定参数个数。
|
||||
|
||||
若参数个数小于零则忽略并使用 `param`。
|
||||
|
||||
## modifiers <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun modifiers(conditions: ModifierConditions)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Constructor` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件。
|
||||
|
||||
## emptyParam <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun emptyParam()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Constructor` 空参数、无参数。
|
||||
|
||||
## param <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun param(vararg paramType: Any)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `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)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Constructor` 参数条件。
|
||||
|
||||
::: danger
|
||||
|
||||
无参 **Constructor** 请使用 **emptyParam** 设置查找条件。
|
||||
|
||||
有参 **Constructor** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(numRange: IntRange)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Constructor` 参数个数范围。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数范围。
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(conditions: CountConditions)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Constructor` 参数个数条件。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数条件。
|
@@ -0,0 +1,93 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# FieldRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class FieldRules internal constructor(internal val rulesData: FieldRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Field` 查找条件实现类。
|
||||
|
||||
## name <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var name: String
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Field` 名称。
|
||||
|
||||
## type <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var type: Any?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Field` 类型。
|
||||
|
||||
可不填写类型。
|
||||
|
||||
## modifiers <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun modifiers(conditions: ModifierConditions)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Field` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件。
|
||||
|
||||
## name <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun name(conditions: NameConditions)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Field` 名称条件。
|
||||
|
||||
## type <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun type(conditions: ObjectConditions)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Field` 类型条件。
|
||||
|
||||
可不填写类型。
|
@@ -0,0 +1,33 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# MemberRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class MemberRules internal constructor(internal val rulesData: MemberRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Member` 查找条件实现类。
|
||||
|
||||
## modifiers <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun modifiers(conditions: ModifierConditions)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Member` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件。
|
@@ -0,0 +1,205 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# MethodRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class MethodRules internal constructor(internal val rulesData: MethodRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Method` 查找条件实现类。
|
||||
|
||||
## name <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var name: String
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 名称。
|
||||
|
||||
## paramCount <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var paramCount: Int
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此变量指定参数个数。
|
||||
|
||||
若参数个数小于零则忽略并使用 `param`。
|
||||
|
||||
## returnType <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var returnType: Any?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 返回值。
|
||||
|
||||
可不填写返回值。
|
||||
|
||||
## modifiers <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun modifiers(conditions: ModifierConditions)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件。
|
||||
|
||||
## emptyParam <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun emptyParam()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 空参数、无参数。
|
||||
|
||||
## param <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun param(vararg paramType: Any)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `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)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 参数条件。
|
||||
|
||||
::: danger
|
||||
|
||||
无参 **Method** 请使用 **emptyParam** 设置查找条件。
|
||||
|
||||
有参 **Method** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
|
||||
|
||||
:::
|
||||
|
||||
## name <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun name(conditions: NameConditions)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 名称条件。
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(numRange: IntRange)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 参数个数范围。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数范围。
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(conditions: CountConditions)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 参数个数条件。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数条件。
|
||||
|
||||
## returnType <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun returnType(conditions: ObjectConditions)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 返回值条件。
|
||||
|
||||
可不填写返回值。
|
@@ -0,0 +1,73 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# MemberRulesResult <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class MemberRulesResult internal constructor(private val rulesData: MemberRulesData)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当前 `Member` 查找条件结果实现类。
|
||||
|
||||
## none <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun none(): MemberRulesResult
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置当前 `Member` 在查找条件中个数为 `0`。
|
||||
|
||||
## count <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun count(num: Int): MemberRulesResult
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置当前 `Member` 在查找条件中需要全部匹配的个数。
|
||||
|
||||
## count <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun count(numRange: IntRange): MemberRulesResult
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置当前 `Member` 在查找条件中需要全部匹配的个数范围。
|
||||
|
||||
## count <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun count(conditions: CountConditions): MemberRulesResult
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置当前 `Member` 在查找条件中需要全部匹配的个数条件。
|
@@ -0,0 +1,615 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# ConstructorFinder <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class ConstructorFinder internal constructor(override val classSet: Class<*>) : MemberBaseFinder
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Constructor` 查找类。
|
||||
|
||||
可通过指定类型查找指定 `Constructor` 或一组 `Constructor`。
|
||||
|
||||
## paramCount <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var paramCount: Int
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Constructor` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此变量指定参数个数。
|
||||
|
||||
若参数个数小于零则忽略并使用 `param`。
|
||||
|
||||
## modifiers <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun modifiers(conditions: ModifierConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Constructor` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件,默认模糊查找并取第一个匹配的 `Constructor`。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## emptyParam <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun emptyParam(): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Constructor` 空参数、无参数。
|
||||
|
||||
## param <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun param(vararg paramType: Any): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Constructor` 参数条件。
|
||||
|
||||
::: danger
|
||||
|
||||
无参 **Constructor** 请使用 **emptyParam** 设置查找条件。
|
||||
|
||||
有参 **Constructor** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(num: Int): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Constructor` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数。
|
||||
|
||||
若参数个数小于零则忽略并使用 `param`。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(numRange: IntRange): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Constructor` 参数个数范围。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数范围。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(conditions: CountConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Constructor` 参数个数条件。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数条件。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## superClass <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun superClass(isOnlySuperClass: Boolean)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置在 `classSet` 的所有父类中查找当前 `Constructor`。
|
||||
|
||||
::: warning
|
||||
|
||||
若当前 **classSet** 的父类较多可能会耗时,API 会自动循环到父类继承是 **Any** 前的最后一个类。
|
||||
|
||||
:::
|
||||
|
||||
## RemedyPlan <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class RemedyPlan internal constructor()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Constructor` 重查找实现类,可累计失败次数直到查找成功。
|
||||
|
||||
### constructor <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun constructor(initiate: ConstructorConditions)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建需要重新查找的 `Constructor`。
|
||||
|
||||
你可以添加多个备选 `Constructor`,直到成功为止,若最后依然失败,将停止查找并输出错误日志。
|
||||
|
||||
### Result <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Result internal constructor()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `RemedyPlan` 结果实现类。
|
||||
|
||||
#### onFind <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun onFind(initiate: HashSet<Constructor<*>>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当在 `RemedyPlan` 中找到结果时。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以方便地对重查找的 `Constructor` 实现 `onFind` 方法。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Constructor` 查找结果实现类。
|
||||
|
||||
### result <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun result(initiate: Result.() -> Unit): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建监听结果事件方法体。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以使用 `lambda` 形式创建 `Result` 类。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
constructor {
|
||||
// Your code here.
|
||||
}.result {
|
||||
get().call()
|
||||
all()
|
||||
remedys {}
|
||||
onNoSuchConstructor {}
|
||||
}
|
||||
```
|
||||
|
||||
### get <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun get(): Instance
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Constructor` 实例处理类。
|
||||
|
||||
若有多个 `Constructor` 结果只会返回第一个。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 请使用 **wait** 回调结果方法。
|
||||
|
||||
:::
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以通过获得方法所在实例来执行构造方法创建新的实例对象。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
constructor {
|
||||
// Your code here.
|
||||
}.get().call()
|
||||
```
|
||||
|
||||
你可以 `cast` 构造方法为指定类型的实例对象。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
constructor {
|
||||
// Your code here.
|
||||
}.get().newInstance<TestClass>()
|
||||
```
|
||||
|
||||
::: danger
|
||||
|
||||
若构造方法含有参数则后方参数必填。
|
||||
|
||||
:::
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
constructor {
|
||||
// Your code here.
|
||||
}.get().newInstance<TestClass>("param1", "param2")
|
||||
```
|
||||
|
||||
### all <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun all(): ArrayList<Instance>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Constructor` 实例处理类数组。
|
||||
|
||||
返回全部查找条件匹配的多个 `Constructor` 实例结果。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以通过此方法来获得当前条件结果中匹配的全部 `Constructor`。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
constructor {
|
||||
// Your code here.
|
||||
}.all().forEach { instance ->
|
||||
instance.call(...)
|
||||
}
|
||||
```
|
||||
|
||||
### give <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun give(): Constructor<*>?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Constructor` 本身。
|
||||
|
||||
若有多个 `Constructor` 结果只会返回第一个。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回 `null`。
|
||||
|
||||
### giveAll <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun giveAll(): HashSet<Constructor<*>>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Constructor` 本身数组。
|
||||
|
||||
返回全部查找条件匹配的多个 `Constructor` 实例。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回空的 `HashSet`。
|
||||
|
||||
### wait <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun wait(initiate: Instance.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Constructor` 实例处理类,配合 `RemedyPlan` 使用。
|
||||
|
||||
若有多个 `Constructor` 结果只会返回第一个。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 必须使用此方法才能获得结果。
|
||||
|
||||
若你没有设置 **remedys** 此方法将不会被回调。
|
||||
|
||||
:::
|
||||
|
||||
### waitAll <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun waitAll(initiate: ArrayList<Instance>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Constructor` 实例处理类数组,配合 `RemedyPlan` 使用。
|
||||
|
||||
返回全部查找条件匹配的多个 `Constructor` 实例结果。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 必须使用此方法才能获得结果。
|
||||
|
||||
若你没有设置 **remedys** 此方法将不会被回调。
|
||||
|
||||
:::
|
||||
|
||||
### remedys <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun remedys(initiate: RemedyPlan.() -> Unit): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建 `Constructor` 重查找功能。
|
||||
|
||||
**功能示例**
|
||||
|
||||
当你遇到一种 `Constructor` 可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchConstructor` 捕获异常二次查找 `Constructor`。
|
||||
|
||||
若第一次查找失败了,你还可以在这里继续添加此方法体直到成功为止。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 监听找不到 `Constructor` 时。
|
||||
|
||||
只会返回第一次的错误信息,不会返回 `RemedyPlan` 的错误信息。
|
||||
|
||||
### ignored <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun ignored(): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 忽略异常并停止打印任何错误日志。
|
||||
|
||||
::: warning
|
||||
|
||||
此时若要监听异常结果,你需要手动实现 **onNoSuchConstructor** 方法。
|
||||
|
||||
:::
|
||||
|
||||
### Instance <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Instance internal constructor(private val constructor: Constructor<*>?)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Constructor` 实例处理类。
|
||||
|
||||
#### call <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun call(vararg args: Any?): Any?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行 `Constructor` 创建目标实例,不指定目标实例类型。
|
||||
|
||||
#### newInstance <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun <T> newInstance(vararg args: Any?): T?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行 `Constructor` 创建目标实例 ,指定 `T` 目标实例类型。
|
@@ -0,0 +1,819 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# FieldFinder <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class FieldFinder internal constructor(override val classSet: Class<*>?) : MemberBaseFinder
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Field` 查找类。
|
||||
|
||||
可通过指定类型查找指定 `Field` 或一组 `Field`。
|
||||
|
||||
## name <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var name: String
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Field` 名称。
|
||||
|
||||
::: danger
|
||||
|
||||
若不填写名称则必须存在一个其它条件。
|
||||
|
||||
:::
|
||||
|
||||
## type <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var type: Any?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Field` 类型。
|
||||
|
||||
可不填写类型。
|
||||
|
||||
## modifiers <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun modifiers(conditions: ModifierConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Field` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## order <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun order(): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 顺序筛选字节码的下标。
|
||||
|
||||
## name <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun name(value: String): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Field` 名称。
|
||||
|
||||
::: danger
|
||||
|
||||
若不填写名称则必须存在一个其它条件。
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## name <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun name(conditions: NameConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Field` 名称条件。
|
||||
|
||||
::: danger
|
||||
|
||||
若不填写名称则必须存在一个其它条件。
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## type <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun type(value: Any): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Field` 类型。
|
||||
|
||||
可不填写类型。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## type <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun type(conditions: ObjectConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Field` 类型条件。
|
||||
|
||||
可不填写类型。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## superClass <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun superClass(isOnlySuperClass: Boolean)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置在 `classSet` 的所有父类中查找当前 `Field`。
|
||||
|
||||
::: warning
|
||||
|
||||
若当前 **classSet** 的父类较多可能会耗时,API 会自动循环到父类继承是 **Any** 前的最后一个类。
|
||||
|
||||
:::
|
||||
|
||||
## RemedyPlan <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class RemedyPlan internal constructor()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Field` 重查找实现类,可累计失败次数直到查找成功。
|
||||
|
||||
### field <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun field(initiate: FieldConditions): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建需要重新查找的 `Field`。
|
||||
|
||||
你可以添加多个备选 `Field`,直到成功为止,若最后依然失败,将停止查找并输出错误日志。
|
||||
|
||||
### Result <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Result internal constructor()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `RemedyPlan` 结果实现类。
|
||||
|
||||
#### onFind <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun onFind(initiate: HashSet<Field>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当在 `RemedyPlan` 中找到结果时。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以方便地对重查找的 `Field` 实现 `onFind` 方法。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Field` 查找结果实现类。
|
||||
|
||||
### result <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun result(initiate: Result.() -> Unit): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建监听结果事件方法体。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以使用 `lambda` 形式创建 `Result` 类。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Field` 实例处理类。
|
||||
|
||||
若有多个 `Field` 结果只会返回第一个。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以轻松地得到 `Field` 的实例以及使用它进行设置实例。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
// Your code here.
|
||||
}.get(instance).set("something")
|
||||
```
|
||||
|
||||
如果你取到的是静态 `Field`,可以不需要设置实例。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
// Your code here.
|
||||
}.get().set("something")
|
||||
```
|
||||
|
||||
### all <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun all(instance: Any?): ArrayList<Instance>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Field` 实例处理类数组。
|
||||
|
||||
返回全部查找条件匹配的多个 `Field` 实例结果。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以通过此方法来获得当前条件结果中匹配的全部 `Field`,其 `Field` 所在实例用法与 `get` 相同。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
// Your code here.
|
||||
}.all(instance).forEach { instance ->
|
||||
instance.self
|
||||
}
|
||||
```
|
||||
|
||||
### give <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun give(): Field?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Field` 本身。
|
||||
|
||||
若有多个 Field 结果只会返回第一个。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回 `null`。
|
||||
|
||||
### giveAll <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun giveAll(): HashSet<Field>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Field` 本身数组。
|
||||
|
||||
返回全部查找条件匹配的多个 `Field` 实例。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回空的 `HashSet`。
|
||||
|
||||
### wait <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun wait(instance: Any?, initiate: Instance.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Field` 实例处理类,配合 `RemedyPlan` 使用。
|
||||
|
||||
若有多个 `Field` 结果只会返回第一个。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 必须使用此方法才能获得结果。
|
||||
|
||||
若你没有设置 **remedys** 此方法将不会被回调。
|
||||
|
||||
:::
|
||||
|
||||
### waitAll <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun waitAll(instance: Any?, initiate: ArrayList<Instance>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Field` 实例处理类数组,配合 `RemedyPlan` 使用。
|
||||
|
||||
返回全部查找条件匹配的多个 `Field` 实例结果。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 必须使用此方法才能获得结果。
|
||||
|
||||
若你没有设置 **remedys** 此方法将不会被回调。
|
||||
|
||||
:::
|
||||
|
||||
### remedys <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun remedys(initiate: RemedyPlan.() -> Unit): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建 `Field` 重查找功能。
|
||||
|
||||
**功能示例**
|
||||
|
||||
当你遇到一种 `Field` 可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchField` 捕获异常二次查找 `Field`。
|
||||
|
||||
若第一次查找失败了,你还可以在这里继续添加此方法体直到成功为止。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 监听找不到 `Field` 时。
|
||||
|
||||
### ignored <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun ignored(): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 忽略异常并停止打印任何错误日志。
|
||||
|
||||
::: 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?)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `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?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得当前 `Field` 自身 `self` 实例的类操作对象 `CurrentClass`。
|
||||
|
||||
#### cast <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun <T> cast(): T?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到当前 `Field` 实例。
|
||||
|
||||
#### byte <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun byte(): Byte?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到当前 `Field` Byte 实例。
|
||||
|
||||
#### int <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun int(): Int
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到当前 `Field` Int 实例。
|
||||
|
||||
#### long <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun long(): Long
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到当前 `Field` Long 实例。
|
||||
|
||||
#### short <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun short(): Short
|
||||
```
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到当前 `Field` Short 实例。
|
||||
|
||||
#### double <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun double(): Double
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到当前 `Field` Double 实例。
|
||||
|
||||
#### float <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun float(): Float
|
||||
```
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到当前 `Field` Float 实例。
|
||||
|
||||
#### string <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun string(): String
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到当前 `Field` String 实例。
|
||||
|
||||
#### char <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun char(): Char
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到当前 `Field` Char 实例。
|
||||
|
||||
#### boolean <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun boolean(): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到当前 `Field` Boolean 实例。
|
||||
|
||||
#### any <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun any(): Any?
|
||||
```
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到当前 `Field` Any 实例。
|
||||
|
||||
#### array <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> array(): Array<T>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到当前 `Field` Array 实例。
|
||||
|
||||
#### list <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> list(): List<T>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到当前 `Field` List 实例。
|
||||
|
||||
#### set <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun set(any: Any?)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置当前 `Field` 实例。
|
||||
|
||||
#### setTrue <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun setTrue()
|
||||
```
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置当前 `Field` 实例为 `true`。
|
||||
|
||||
::: danger
|
||||
|
||||
请确保实例对象类型为 **Boolean**。
|
||||
|
||||
:::
|
||||
|
||||
#### setFalse <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun setFalse()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置当前 `Field` 实例为 `false`。
|
||||
|
||||
::: danger
|
||||
|
||||
请确保实例对象类型为 **Boolean**。
|
||||
|
||||
:::
|
||||
|
||||
#### setNull <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun setNull()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置当前 `Field` 实例为 `null`。
|
@@ -0,0 +1,891 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# MethodFinder <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class MethodFinder internal constructor(override val classSet: Class<*>) : MemberBaseFinder
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Method` 查找类。
|
||||
|
||||
可通过指定类型查找指定 `Method` 或一组 `Method`。
|
||||
|
||||
## name <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var name: String
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 名称。
|
||||
|
||||
::: danger
|
||||
|
||||
若不填写名称则必须存在一个其它条件。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var paramCount: Int
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此变量指定参数个数。
|
||||
|
||||
若参数个数小于零则忽略并使用 `param`。
|
||||
|
||||
## returnType <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
var returnType: Any?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 返回值,可不填写返回值。
|
||||
|
||||
## modifiers <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun modifiers(conditions: ModifierConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## emptyParam <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun emptyParam(): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 空参数、无参数。
|
||||
|
||||
## param <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun param(vararg paramType: Any): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 参数条件。
|
||||
|
||||
::: danger
|
||||
|
||||
无参 **Method** 请使用 **emptyParam** 设置查找条件。
|
||||
|
||||
有参 **Method** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## order <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun order(): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 顺序筛选字节码的下标。
|
||||
|
||||
## name <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun name(value: String): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 名称。
|
||||
|
||||
::: danger
|
||||
|
||||
若不填写名称则必须存在一个其它条件。
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## name <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun name(conditions: NameConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 名称条件。
|
||||
|
||||
::: danger
|
||||
|
||||
若不填写名称则必须存在一个其它条件。
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(num: Int): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数。
|
||||
|
||||
若参数个数小于零则忽略并使用 `param`。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(numRange: IntRange): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 参数个数范围。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数范围。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## paramCount <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun paramCount(conditions: CountConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 参数个数条件。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数条件。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## returnType <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun returnType(value: Any): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 返回值。
|
||||
|
||||
可不填写返回值。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## returnType <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun returnType(conditions: ObjectConditions): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 返回值条件。
|
||||
|
||||
可不填写返回值。
|
||||
|
||||
::: danger
|
||||
|
||||
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
|
||||
|
||||
:::
|
||||
|
||||
## superClass <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun superClass(isOnlySuperClass: Boolean)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置在 `classSet` 的所有父类中查找当前 `Method`。
|
||||
|
||||
::: warning
|
||||
|
||||
若当前 **classSet** 的父类较多可能会耗时,API 会自动循环到父类继承是 **Any** 前的最后一个类。
|
||||
|
||||
:::
|
||||
|
||||
## RemedyPlan <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class RemedyPlan internal constructor()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Method` 重查找实现类,可累计失败次数直到查找成功。
|
||||
|
||||
### method <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun method(initiate: MethodConditions): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建需要重新查找的 `Method`。
|
||||
|
||||
你可以添加多个备选 `Method`,直到成功为止,若最后依然失败,将停止查找并输出错误日志。
|
||||
|
||||
### Result <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Result internal constructor()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `RemedyPlan` 结果实现类。
|
||||
|
||||
#### onFind <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun onFind(initiate: HashSet<Method>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当在 `RemedyPlan` 中找到结果时。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以方便地对重查找的 `Method` 实现 `onFind` 方法。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Method` 查找结果实现类。
|
||||
|
||||
### result <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun result(initiate: Result.() -> Unit): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建监听结果事件方法体。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以使用 `lambda` 形式创建 `Result` 类。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Method` 实例处理类。
|
||||
|
||||
若有多个 `Method` 结果只会返回第一个。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 请使用 **wait** 回调结果方法。
|
||||
|
||||
:::
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以通过获得方法所在实例来执行 `Method`。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
// Your code here.
|
||||
}.get(instance).call()
|
||||
```
|
||||
|
||||
若当前为静态方法,你可以不设置实例。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
// Your code here.
|
||||
}.get().call()
|
||||
```
|
||||
|
||||
### all <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun all(instance: Any?): ArrayList<Instance>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Method` 实例处理类数组。
|
||||
|
||||
返回全部查找条件匹配的多个 `Method` 实例结果。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以通过此方法来获得当前条件结果中匹配的全部 `Method`,其方法所在实例用法与 `get` 相同。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
// Your code here.
|
||||
}.all(instance).forEach { instance ->
|
||||
instance.call(...)
|
||||
}
|
||||
```
|
||||
|
||||
### give <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun give(): Method?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Method` 本身。
|
||||
|
||||
若有多个 `Method` 结果只会返回第一个。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回 `null`。
|
||||
|
||||
### giveAll <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun giveAll(): HashSet<Method>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Method` 本身数组。
|
||||
|
||||
返回全部查找条件匹配的多个 `Method` 实例。
|
||||
|
||||
在查找条件找不到任何结果的时候将返回空的 `HashSet`。
|
||||
|
||||
### wait <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun wait(instance: Any?, initiate: Instance.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Method` 实例处理类,配合 `RemedyPlan` 使用。
|
||||
|
||||
若有多个 `Method` 结果只会返回第一个。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 必须使用此方法才能获得结果。
|
||||
|
||||
若你没有设置 **remedys** 此方法将不会被回调。
|
||||
|
||||
:::
|
||||
|
||||
### waitAll <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun waitAll(instance: Any?, initiate: ArrayList<Instance>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Method` 实例处理类数组,配合 `RemedyPlan` 使用。
|
||||
|
||||
返回全部查找条件匹配的多个 `Method` 实例结果。
|
||||
|
||||
::: danger
|
||||
|
||||
若你设置了 **remedys** 必须使用此方法才能获得结果。
|
||||
|
||||
若你没有设置 **remedys** 此方法将不会被回调。
|
||||
|
||||
:::
|
||||
|
||||
### remedys <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun remedys(initiate: RemedyPlan.() -> Unit): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建 `Method` 重查找功能。
|
||||
|
||||
**功能示例**
|
||||
|
||||
当你遇到一种 `Method` 可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchMethod` 捕获异常二次查找 `Method`。
|
||||
|
||||
若第一次查找失败了,你还可以在这里继续添加此方法体直到成功为止。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 监听找不到 `Method` 时。
|
||||
|
||||
只会返回第一次的错误信息,不会返回 `RemedyPlan` 的错误信息。
|
||||
|
||||
### ignored <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun ignored(): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 忽略异常并停止打印任何错误日志。
|
||||
|
||||
::: 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?)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Method` 实例处理类。
|
||||
|
||||
#### call <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun call(vararg args: Any?): Any?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行 `Method`,不指定返回值类型。
|
||||
|
||||
#### invoke <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun <T> invoke(vararg args: Any?): T?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行 `Method`,指定 `T` 返回值类型。
|
||||
|
||||
#### byte <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun byte(vararg args: Any?): Byte?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行 `Method`,指定 Byte 返回值类型。
|
||||
|
||||
#### int <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun int(vararg args: Any?): Int
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行 `Method`,指定 Int 返回值类型。
|
||||
|
||||
#### long <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun long(vararg args: Any?): Long
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行 `Method`,指定 Long 返回值类型。
|
||||
|
||||
#### short <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun short(vararg args: Any?): Short
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行 `Method`,指定 Short 返回值类型。
|
||||
|
||||
#### double <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun double(vararg args: Any?): Double
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行 `Method`,指定 Double 返回值类型。
|
||||
|
||||
#### float <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun float(vararg args: Any?): Float
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行 `Method`,指定 Float 返回值类型。
|
||||
|
||||
#### string <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun string(vararg args: Any?): String
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行 `Method`,指定 String 返回值类型。
|
||||
|
||||
#### char <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun char(vararg args: Any?): Char
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行 `Method`,指定 Char 返回值类型。
|
||||
|
||||
#### boolean <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
fun boolean(vararg args: Any?): Boolean
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行 `Method`,指定 Boolean 返回值类型。
|
||||
|
||||
### array <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> array(vararg args: Any?): Array<T>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行 `Method`,指定 Array 返回值类型。
|
||||
|
||||
### list <span class="symbol">- method</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inline fun <reified T> list(vararg args: Any?): List<T>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行 `Method`,指定 List 返回值类型。
|
@@ -0,0 +1,15 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# ComponentTypeFactory <span class="symbol">- kt</span>
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 这是一个预置反射类型的常量类,主要为 `Android` 相关组件的 `Class` 内容,跟随版本更新会逐一进行增加。
|
||||
|
||||
详情可 [点击这里](https://github.com/fankes/YukiReflection/blob/master/yukireflection/src/api/kotlin/com/highcapable/yukireflection/type/android/ComponentTypeFactory.kt) 进行查看。
|
@@ -0,0 +1,15 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# GraphicsTypeFactory <span class="symbol">- kt</span>
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 这是一个预置反射类型的常量类,主要为 `Android` 相关 `Graphics` 的 `Class` 内容,跟随版本更新会逐一进行增加。
|
||||
|
||||
详情可 [点击这里](https://github.com/fankes/YukiReflection/blob/master/yukireflection/src/api/kotlin/com/highcapable/yukireflection/type/android/GraphicsTypeFactory.kt) 进行查看。
|
@@ -0,0 +1,15 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# ViewTypeFactory <span class="symbol">- kt</span>
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 这是一个预置反射类型的常量类,主要为 `Android` 相关 `Widget` 的 `Class` 内容,跟随版本更新会逐一进行增加。
|
||||
|
||||
详情可 [点击这里](https://github.com/fankes/YukiReflection/blob/master/yukireflection/src/api/kotlin/com/highcapable/yukireflection/type/android/ViewTypeFactory.kt) 进行查看。
|
@@ -0,0 +1,27 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# DefinedTypeFactory <span class="symbol">- kt</span>
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 这是一个内部类型的定义常量类,主要用于反射 API 相关用法的延伸。
|
||||
|
||||
## VagueType <span class="symbol">- field</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
val VagueType: Class<*>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到模糊类型。
|
@@ -0,0 +1,15 @@
|
||||
---
|
||||
pageClass: code-page
|
||||
---
|
||||
|
||||
# VariableTypeFactory <span class="symbol">- kt</span>
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 这是一个预置反射类型的常量类,主要为 `Java` 相关基本变量类型的 `Class` 内容,跟随版本更新会逐一进行增加。
|
||||
|
||||
详情可 [点击这里](https://github.com/fankes/YukiReflection/blob/master/yukireflection/src/api/kotlin/com/highcapable/yukireflection/type/java/VariableTypeFactory.kt) 进行查看。
|
121
docs-source/src/zh-cn/config/api-example.md
Normal file
121
docs-source/src/zh-cn/config/api-example.md
Normal file
@@ -0,0 +1,121 @@
|
||||
# API 基本配置
|
||||
|
||||
> 这里介绍了 `YukiReflection` 的基本配置方法。
|
||||
|
||||
`YukiReflection` 无需一些复杂的配置即可直接开始使用,且不会与 `Java` 原生的反射 API 冲突。
|
||||
|
||||
你可以在使用之前对 `YukiReflection` 进行一些功能配置。
|
||||
|
||||
## 获取 API 版本
|
||||
|
||||
你可以通过如下方式获取当前 `YukiReflection` 的 API 版本。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 获取版本名称
|
||||
val versionName = YukiReflection.API_VERSION_NAME
|
||||
// 获取版本号
|
||||
val versionCode = YukiReflection.API_VERSION_CODE
|
||||
```
|
||||
|
||||
你可以通过获取版本进行一些不同版本差异的判断或用于显示在关于信息中。
|
||||
|
||||
::: tip
|
||||
|
||||
更多功能请参考 [YukiReflection](../api/public/com/highcapable/yukireflection/YukiReflection)。
|
||||
|
||||
:::
|
||||
|
||||
## 配置 API 相关功能
|
||||
|
||||
你可以通过 `YukiReflection.configs { ... }` 方法或 `YukiReflection.Configs` 来配置相关功能。
|
||||
|
||||
### 自定义调试日志标签
|
||||
|
||||
你可以使用如下方式来自定义调试日志的标签。
|
||||
|
||||
API 内部的日志将会使用此标签进行打印。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 通过 configs 方法
|
||||
YukiReflection.configs {
|
||||
debugTag = "YourCustomTag"
|
||||
}
|
||||
// 直接设置
|
||||
YukiReflection.Configs.debugTag = "YourCustomTag"
|
||||
```
|
||||
|
||||
### 启用或禁用 Debug 模式
|
||||
|
||||
你可以使用如下方式来启用或禁用 Debug 模式。
|
||||
|
||||
Debug 模式默认是关闭的,启用后将会打印详细日志 (例如反射查找功能的耗时) 到控制台。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 通过 configs 方法
|
||||
YukiReflection.configs {
|
||||
isDebug = true
|
||||
}
|
||||
// 直接设置
|
||||
YukiReflection.Configs.isDebug = true
|
||||
```
|
||||
|
||||
### 启用或禁用调试日志的输出功能
|
||||
|
||||
你可以使用如下方式来启用或禁用调试日志的输出功能。
|
||||
|
||||
此功能默认启用,关闭后将会停用 `YukiReflection` 对全部日志的输出。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 通过 configs 方法
|
||||
YukiReflection.configs {
|
||||
isAllowPrintingLogs = true
|
||||
}
|
||||
// 直接设置
|
||||
YukiReflection.Configs.isAllowPrintingLogs = true
|
||||
```
|
||||
|
||||
### 启用或禁用 Member 缓存
|
||||
|
||||
你可以使用如下方式来启用或禁用 `Member` 缓存。
|
||||
|
||||
为防止 `Member` 复用过高造成的系统 GC 问题,此功能默认启用。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 通过 configs 方法
|
||||
YukiReflection.configs {
|
||||
isEnableMemberCache = true
|
||||
}
|
||||
// 直接设置
|
||||
YukiReflection.Configs.isEnableMemberCache = true
|
||||
```
|
||||
|
||||
### 使用 configs 方法配置
|
||||
|
||||
为了一次性配置多个功能,你可以直接使用 `YukiReflection.configs { ... }` 方法进行配置。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
YukiReflection.configs {
|
||||
debugTag = "YourCustomTag"
|
||||
isDebug = true
|
||||
isAllowPrintingLogs = true
|
||||
isEnableMemberCache = true
|
||||
}
|
||||
```
|
||||
|
||||
::: tip
|
||||
|
||||
更多功能请参考 [YukiReflection.configs](../api/public/com/highcapable/yukireflection/YukiReflection#configs-method) 方法、[YukiReflection.Configs](../api/public/com/highcapable/yukireflection/YukiReflection#configs-object)。
|
||||
|
||||
:::
|
442
docs-source/src/zh-cn/config/api-exception.md
Normal file
442
docs-source/src/zh-cn/config/api-exception.md
Normal file
@@ -0,0 +1,442 @@
|
||||
---
|
||||
pageClass: hidden-anchor-page
|
||||
---
|
||||
|
||||
# API 异常处理
|
||||
|
||||
> 异常是在开发过程经常遇到的主要问题,这里介绍了 `YukiReflection` 在使用过程中可能遇到的常见异常以及处理方式。
|
||||
|
||||
这里的异常说明只会同步最新的 API 版本,较旧的 API 版本的异常将不会再进行说明,请始终保持 API 版本为最新。
|
||||
|
||||
## 非阻断异常
|
||||
|
||||
> 这些异常不会导致 APP 停止运行 (FC),但是会在控制台打印 `E` 级别的日志,也可能会停止继续执行相关功能。
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
Method/Constructor/Field match type "**TYPE**" not allowed
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
在查找方法、构造方法以及变量时设置了不允许的参数类型。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 查找一个方法
|
||||
method {
|
||||
// ❗设置了无效的类型举例
|
||||
param(false, 1, 0)
|
||||
// ❗设置了无效的类型举例
|
||||
returnType = false
|
||||
}
|
||||
|
||||
// 查找一个变量
|
||||
field {
|
||||
// ❗设置了无效的类型举例
|
||||
type = false
|
||||
}
|
||||
```
|
||||
|
||||
**解决方案**
|
||||
|
||||
在查找中 `param`、`returnType`、`type` 中仅接受 `Class`、`String`、`VariousClass` 类型的传值,不可传入参数实例。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 查找一个方法
|
||||
method {
|
||||
// ✅ 正确的使用方法举例
|
||||
param(BooleanType, IntType, IntType)
|
||||
// ✅ 正确的使用方法举例
|
||||
returnType = BooleanType
|
||||
// ✅ 以下方案也是正确的
|
||||
returnType = "java.lang.Boolean"
|
||||
}
|
||||
|
||||
// 查找一个变量
|
||||
field {
|
||||
// ✅ 正确的使用方法举例
|
||||
type = BooleanType
|
||||
}
|
||||
```
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
NoSuchMethod/NoSuchConstructor/NoSuchField happend in \[**NAME**\]
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
在查找方法、构造方法以及变量时并未找到目标方法、构造方法以及变量。
|
||||
|
||||
**解决方案**
|
||||
|
||||
请确认你的查找条件是否能正确匹配到目标 `Class` 中的指定方法、构造方法以及变量。
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
Trying **COUNT** times and all failure by RemedyPlan
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
使用 `RemedyPlan` 重新查找方法、构造方法、变量时依然没有找到方法、构造方法、变量。
|
||||
|
||||
**解决方案**
|
||||
|
||||
请确认你设置的 `RemedyPlan` 参数以及当前 APP 内存在的 `Class`,再试一次。
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
You must set a condition when finding a Method/Constructor/Field
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
在查找方法、构造方法以及变量时并未设置任何条件。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
// 这里没有设置任何条件
|
||||
}
|
||||
```
|
||||
|
||||
**解决方案**
|
||||
|
||||
请将查找条件补充完整并再试一次。
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
Can't find this Class in \[**CLASSLOADER**\]: **CONTENT** Generated by YukiReflection#ReflectionTool
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
通过 `ClassLoader.searchClass` 找不到需要查找的 `Class` 对象。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
customClassLoader?.searchClass {
|
||||
from(...)
|
||||
// ...
|
||||
}.get()
|
||||
```
|
||||
|
||||
**解决方案**
|
||||
|
||||
这是一个安全异常,请检查你设置的条件,使用相关工具查看所在 **Dex** 中的 `Class` 以及字节码对象特征,并再试一次。
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
Can't find this Method/Constructor/Field in \[**CLASS**\]: **CONTENT** Generated by YukiReflection#ReflectionTool
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
通过指定条件找不到需要查找的方法、构造方法以及变量。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
TargetClass.method {
|
||||
name = "test"
|
||||
param(BooleanType)
|
||||
}
|
||||
```
|
||||
|
||||
**解决方案**
|
||||
|
||||
这是一个安全异常,请检查你设置的条件,使用相关工具查看所在 `Class` 中的字节码对象特征,并再试一次。
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
The number of VagueType must be at least less than the count of paramTypes
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
在 `Method`、`Constructor` 查找条件中错误地使用了 `VagueType`。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
TargetClass.method {
|
||||
name = "test"
|
||||
// <情景1>
|
||||
param(VagueType)
|
||||
// <情景2>
|
||||
param(VagueType, VagueType ...)
|
||||
}
|
||||
```
|
||||
|
||||
**解决方案**
|
||||
|
||||
`VagueType` 不能在方法、构造方法参数中完全填充,若存在这样的需求请使用 `paramCount`。
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
Field match type class is not found
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
在查找变量时所设置的查找条件中 `type` 的 `Class` 实例未被找到。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
name = "test"
|
||||
// 假设这里设置的 type 的 Class 并不存在
|
||||
type = "com.example.TestClass"
|
||||
}
|
||||
```
|
||||
|
||||
**解决方案**
|
||||
|
||||
请检查查找条件中 `type` 的 `Class` 是否存在,然后再试一次。
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
Method match returnType class is not found
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
在查找方法时所设置的查找条件中 `returnType` 的 `Class` 实例未被找到。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
name = "test"
|
||||
// 假设这里设置的 returnType 的 Class 并不存在
|
||||
returnType = "com.example.TestClass"
|
||||
}
|
||||
```
|
||||
|
||||
**解决方案**
|
||||
|
||||
请检查查找条件中 `returnType` 的 `Class` 是否存在,然后再试一次。
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger loggerE
|
||||
|
||||
Method/Constructor match paramType\[**INDEX**\] class is not found
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
在查找方法、构造方法时所设置的查找条件中 `param` 的 `index` 号下标的 `Class` 实例未被找到。
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
name = "test"
|
||||
// 假设这里设置的 1 号下标的 Class 并不存在
|
||||
param(StringClass, "com.example.TestClass", BooleanType)
|
||||
}
|
||||
```
|
||||
|
||||
**解决方案**
|
||||
|
||||
请检查查找条件中 `param` 的 `index` 号下标的 `Class` 是否存在,然后再试一次。
|
||||
|
||||
## 阻断异常
|
||||
|
||||
> 这些异常会直接导致 APP 停止运行 (FC),同时会在控制台打印 `E` 级别的日志。
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger NoClassDefFoundError
|
||||
|
||||
Can't find this Class in \[**CLASSLOADER**\]: **CONTENT** Generated by YukiReflection#ReflectionTool
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
通过 `String.toClass(...)` 或 `classOf<...>()` 找不到需要查找的 `Class` 对象。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
"com.demo.Test".toClass()
|
||||
```
|
||||
|
||||
**解决方案**
|
||||
|
||||
请检查当前字符串或实体匹配到的 `Class` 是否存在于当前 `ClassLoader`,并再试一次。
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger IllegalStateException
|
||||
|
||||
ClassLoader \[**CLASSLOADER**\] is not a DexClassLoader
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
使用 `ClassLoader.searchClass` 查找 `Class` 但是当前 `ClassLoader` 并不继承于 `BaseDexClassLoader`。
|
||||
|
||||
**解决方案**
|
||||
|
||||
这种情况基本不存在,除非当前 APP 引用了非 ART 平台的可执行文件 (但是这种情况还是不会存在) 或当前 `ClassLoader` 为空。
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger IllegalStateException
|
||||
|
||||
VariousClass match failed of those **CLASSES**
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
在使用 `VariousClass` 创建不确定的 `Class` 对象时全部的 `Class` 都没有被找到。
|
||||
|
||||
**解决方案**
|
||||
|
||||
检查当前 APP 内是否存在其中能够匹配的 `Class` 后,再试一次。
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger IllegalStateException
|
||||
|
||||
paramTypes is empty, please use emptyParam() instead
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
在查找方法、构造方法时保留了空的 `param` 方法。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
name = "test"
|
||||
// 括号内没有填写任何参数
|
||||
param()
|
||||
}
|
||||
```
|
||||
|
||||
**解决方案**
|
||||
|
||||
若要标识此方法、构造方法没有参数,你可以有如下设置方法。
|
||||
|
||||
第一种,设置 `emptyParam` (推荐)
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
name = "test"
|
||||
emptyParam()
|
||||
}
|
||||
```
|
||||
|
||||
第二种,设置 `paramCount = 0`
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
name = "test"
|
||||
paramCount = 0
|
||||
}
|
||||
```
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger IllegalStateException
|
||||
|
||||
Cannot create classes cache for "android", please remove "name" param
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
在系统框架 (android) 中使用了 `DexClassFinder` 的缓存功能 `searchClass(name = ...)`。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
searchClass(name = "test") {
|
||||
from(...)
|
||||
// ...
|
||||
}.get()
|
||||
```
|
||||
|
||||
**解决方案**
|
||||
|
||||
由于缓存会将找到的 `Class` 名称存入 `SharedPreferences`,但是系统框架不存在 data 目录,所以请不要在系统框架中使用此功能。
|
||||
|
||||
###### exception
|
||||
|
||||
::: danger IllegalStateException
|
||||
|
||||
Target Class type cannot cast to **TYPE**
|
||||
|
||||
:::
|
||||
|
||||
**异常原因**
|
||||
|
||||
使用 `Class.toClass`、`Class.toClassOrNull`、`GenericClass.argument` 方法将字符串类名转换为目标 `Class` 时声明了错误的类型。
|
||||
|
||||
以下使用 `Class.toClass` 方法来进行示例。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 假设目标类型是 Activity 但是被错误地转换为了 WrongClass 类型
|
||||
val clazz = "android.app.Activity".toClass<WrongClass>()
|
||||
```
|
||||
|
||||
**解决方案**
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// <解决方案 1> 填写正确的类型
|
||||
val clazz1 = "android.app.Activity".toClass<Activity>()
|
||||
// <解决方案 2> 不填写泛型声明
|
||||
val clazz2 = "android.app.Activity".toClass()
|
||||
```
|
||||
|
||||
请确保执行方法后声明的泛型是指定的目标 `Class` 类型,在不确定目标类型的情况下你可以不需要填写泛型声明。
|
56
docs-source/src/zh-cn/guide/home.md
Normal file
56
docs-source/src/zh-cn/guide/home.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# 介绍
|
||||
|
||||
> `YukiReflection` 是一个基于 Android 平台的反射 API。
|
||||
|
||||
## 背景
|
||||
|
||||
这是一个使用 `Kotlin` 基于 `Java` 原生反射 API 重新打造的一套简洁、高效的反射 API。
|
||||
|
||||
`YukiReflection` 同时也是 [YukiHookAPI](https://github.com/fankes/YukiHookAPI) 正在使用的核心功能。
|
||||
|
||||
名称取自 [《ももくり》女主 栗原 雪(Yuki)](https://www.bilibili.com/bangumi/play/ss5016)。
|
||||
|
||||
## 用途
|
||||
|
||||
`YukiReflection` 完全采用 `Kotlin` `lambda` 语法构建。
|
||||
|
||||
它能取代 [Java 原生的反射 API](https://pdai.tech/md/java/basic/java-basic-x-reflection.html),使用更加人性化的语言实现一套更加完善的反射方案。
|
||||
|
||||
## 语言要求
|
||||
|
||||
请使用 `Kotlin`,API 部分代码构成同样兼容 `Java` 但基础反射场景的实现**可能完全无法使用**。
|
||||
|
||||
文档全部的 Demo 示例代码都将使用 `Kotlin` 进行描述,如果你完全不会使用 `Kotlin` 那你将有可能无法使用 `YukiReflection`。
|
||||
|
||||
## 灵感来源
|
||||
|
||||
`YukiReflection` 最初是集成在 [YukiHookAPI](https://github.com/fankes/YukiHookAPI) 项目中的核心功能,现在进行了解耦合,使得这套反射 API 可以在任何 Android 平台的项目中使用。
|
||||
|
||||
现在,我们只需要编写少量的代码,就能实现一个简单的反射调用。
|
||||
|
||||
借助 `Kotlin` 优雅的 `lambda` 写法以及 `YukiReflection`,可以让你的反射逻辑更加美观清晰。
|
||||
|
||||
> 示例如下
|
||||
|
||||
:::: 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")
|
||||
```
|
||||
|
||||
:::
|
||||
::::
|
73
docs-source/src/zh-cn/guide/quick-start.md
Normal file
73
docs-source/src/zh-cn/guide/quick-start.md
Normal file
@@ -0,0 +1,73 @@
|
||||
# 快速开始
|
||||
|
||||
> 集成 `YukiReflection` 到你的项目中。
|
||||
|
||||
## 环境要求
|
||||
|
||||
- Windows 7 及以上/macOS 10.14 及以上/Linux 发行版(Arch/Debian)
|
||||
|
||||
- Android Studio 2021.1 及以上
|
||||
|
||||
- IntelliJ IDEA 2021.1 及以上
|
||||
|
||||
- Kotlin 1.7.0 及以上
|
||||
|
||||
- Android Gradle Plugin 7.0 及以上
|
||||
|
||||
- Gradle 7.0 及以上
|
||||
|
||||
- Jvm 11 及以上
|
||||
|
||||
## 项目要求
|
||||
|
||||
项目需要使用 `Android Studio` 或 `IntelliJ IDEA` 创建且类型为 Android 项目并已集成 `Kotlin` 环境依赖。
|
||||
|
||||
## 集成依赖
|
||||
|
||||
**(可选)** 在你的项目 `build.gradle` 中添加依赖。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```groovy
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
// MavenCentral 有 2 小时缓存,若无法集成最新版本请添加此地址
|
||||
maven { url "https://s01.oss.sonatype.org/content/repositories/releases" }
|
||||
}
|
||||
```
|
||||
|
||||
在你的 app `build.gradle` 中添加依赖。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
// 基础依赖
|
||||
implementation 'com.highcapable.yukireflection:api:<yuki-version>'
|
||||
}
|
||||
```
|
||||
|
||||
请将 **<yuki-version>** 修改为 [这里](../about/changelog) 的最新版本。
|
||||
|
||||
::: danger
|
||||
|
||||
如果你的项目目前正在使用 [YukiHookAPI](https://github.com/fankes/YukiHookAPI),请不要重复集成 **YukiReflection**,因为 **YukiHookAPI** 已经包含了其中的功能且存在针对相关功能的改动,重复集成会造成功能性冲突引发异常,此时你应该前往 **YukiHookAPI** 的 [文档](https://fankes.github.io/YukiHookAPI/zh-cn/) 查看对应使用教程。
|
||||
|
||||
:::
|
||||
|
||||
在你的 app `build.gradle` 中修改 `Kotlin` 的 Jvm 版本为 11 及以上。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```groovy
|
||||
android {
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '11'
|
||||
}
|
||||
}
|
||||
```
|
13
docs-source/src/zh-cn/index.md
Normal file
13
docs-source/src/zh-cn/index.md
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
home: true
|
||||
title: 首页
|
||||
heroImage: /images/logo.png
|
||||
actions:
|
||||
- text: 快速上手
|
||||
link: /zh-cn/guide/home
|
||||
type: primary
|
||||
- text: 更新日志
|
||||
link: /zh-cn/about/changelog
|
||||
type: secondary
|
||||
footer: MIT License | Copyright (C) 2019-2023 HighCapable
|
||||
---
|
Reference in New Issue
Block a user