Osmerion/OptIn
GitHub: Osmerion/OptIn
OptIn 为 Java 生态系统提供了一套声明和使用需要显式选择加入的 API 的标准,帮助开发者在 API 演进过程中安全地管理不稳定或实验性接口。
Stars: 4 | Forks: 0
# 🗹 OptIn
[](https://github.com/Osmerion/OptIn/blob/master/LICENSE)
[](https://maven-badges.herokuapp.com/maven-central/com.osmerion.optin/opt-in)
[](https://javadoc.io/doc/com.osmerion.optin/opt-in)

一个用于声明和使用需要显式 opt-in 的 API 的 Java 标准。
```
// Create a requirement marker
@RequiresOptIn(message = "This API is subject to change and may change without prior notice.")
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface ExperimentalNotifications {}
interface MyNotificationProcessor {
void sendOldNotification();
@ExperimentalNotifications // Declares an opt-in requirement
void sendFancyNewNotification();
}
// Opts-in into the requirement marker
@OptIn(ExperimentalNotifications.class)
void onMessage(MyNotificationProcessor processor) {
processor.sendFancyNewNotification();
}
```
[了解更多!](https://osmerion.github.io/OptIn)
## 从源码构建
### 设置
本项目使用 [Gradle 的 toolchain 支持](https://docs.gradle.org/current/userguide/toolchains.html)
来检测和选择构建所需的 JDK。请查阅
构建脚本以了解需要请求哪些 toolchain。
运行 Gradle 需要安装 JDK 17(或更高版本)。
### 构建
设置完成后,在 Unix/macOS 上使用
以下命令调用相应的 Gradle 任务:
```
./gradlew
```
或者在 Windows 上使用以下命令:
```
gradlew
```
需要记住的重要 Gradle 任务有:
- `clean` - 清理构建结果
- `build` - 组装并测试 Java 库
- `publishToMavenLocal` - 构建并将所有公开的 artifact 安装到
本地的 Maven 仓库中
此外,可以使用 `tasks` 来打印所有可用任务的列表。
## 许可证
### 鸣谢
本项目深受 [Kotlin 的 opt-in 需求机制](https://kotlinlang.org/docs/opt-in-requirements.html) 的启发,并与其兼容。
它旨在为 Java 生态系统引入一个通用且更易于访问的 opt-in 需求标准,以通过强大的静态分析来巩固
代码演进实践。
### OptIn
```
Copyright 2022-2026 Leon Linhart
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
标签:API设计, JS文件枚举, 后台面板检测, 域名枚举, 开发组件, 标准规范, 软件开发