From 28e8a93359f3f107b56b9e666bdfb09cba874c12 Mon Sep 17 00:00:00 2001 From: FalsePattern <30945458+FalsePattern@users.noreply.github.com> Date: Sat, 6 Aug 2022 14:18:55 +0200 Subject: [PATCH] annotation refactor --- .../java/com/falsepattern/lib/StableAPI.java | 20 +++++++++++-------- .../lib/config/ConfigurationManager.java | 14 ++++++------- .../lib/config/SimpleGuiConfig.java | 2 +- .../falsepattern/lib/toasts/SimpleToast.java | 4 ++-- .../com/falsepattern/lib/util/RenderUtil.java | 2 +- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/falsepattern/lib/StableAPI.java b/src/main/java/com/falsepattern/lib/StableAPI.java index d2e0be4..d392e35 100644 --- a/src/main/java/com/falsepattern/lib/StableAPI.java +++ b/src/main/java/com/falsepattern/lib/StableAPI.java @@ -38,7 +38,8 @@ import java.lang.annotation.Target; * fields or non-override methods you may have added if you want to expose those too. *
* NOTICE: You should no longer use this annotation exclusively on classes themselves, and instead, annotate every single - * public or protected member you want to expose as a public API! + * public or protected member you want to expose as a public API! See the {@link Expose} and {@link Internal} annotations + * for extra info. *
* Private members will never be considered stable, and can be removed without notice. *
@@ -48,30 +49,33 @@ import java.lang.annotation.Target; */ @Documented @Retention(RetentionPolicy.RUNTIME) -@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@Target(ElementType.TYPE) @StableAPI(since = "0.6.0") public @interface StableAPI { /** * The version this API was introduced/stabilized in. Used for library version tracking. */ - @StableAPI(since = "0.6.0") String since(); + @StableAPI.Expose + String since(); /** * You may use this annotation if you want a member to have an equal effective {@link #since()} value as its owner * class. *
* Everything else from the {@link StableAPI} class still applies, this is only here for brevity's sake. - * Note that if you add a new field in a version newer than the class, you must use {@link StableAPI} with the - * correct version! + * Note that if you add a method/field in a version newer than the class, you must also specify the correct version! *
* Also note that this only works for class members (methods and fields),
* inner classes still need to use {@link StableAPI}.
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
- @Target(value = {ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
+ @Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
@StableAPI(since = "0.10.0")
- @interface Expose {}
+ @interface Expose {
+ @StableAPI.Expose
+ String since() default "__PARENT__";
+ }
/**
* Use this if you want to explicitly mark specific members of a {@link StableAPI} class as internal-use only.
@@ -81,7 +85,7 @@ public @interface StableAPI {
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
- @Target(value = {ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
+ @Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
@StableAPI(since = "0.10.0")
@interface Internal {}
}
diff --git a/src/main/java/com/falsepattern/lib/config/ConfigurationManager.java b/src/main/java/com/falsepattern/lib/config/ConfigurationManager.java
index 4d05c6e..369ecca 100644
--- a/src/main/java/com/falsepattern/lib/config/ConfigurationManager.java
+++ b/src/main/java/com/falsepattern/lib/config/ConfigurationManager.java
@@ -43,12 +43,12 @@ import java.util.function.BiConsumer;
@StableAPI(since = "0.6.0")
public class ConfigurationManager {
- @StableAPI(since = "0.10.0")
+ @StableAPI.Expose(since = "0.10.0")
public static void initialize(Class>... configClasses) throws ConfigException {
initialize((a, b) -> {}, configClasses);
}
- @StableAPI(since = "0.10.0")
+ @StableAPI.Expose(since = "0.10.0")
public static void initialize(BiConsumer