Skip to content

Commit 28e8a93

Browse files
committed
annotation refactor
1 parent a19adf2 commit 28e8a93

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

src/main/java/com/falsepattern/lib/StableAPI.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
* fields or non-override methods you may have added if you want to expose those too.
3939
* <p>
4040
* NOTICE: You should no longer use this annotation exclusively on classes themselves, and instead, annotate every single
41-
* public or protected member you want to expose as a public API!
41+
* public or protected member you want to expose as a public API! See the {@link Expose} and {@link Internal} annotations
42+
* for extra info.
4243
* <p>
4344
* Private members will never be considered stable, and can be removed without notice.
4445
* <p>
@@ -48,30 +49,33 @@
4849
*/
4950
@Documented
5051
@Retention(RetentionPolicy.RUNTIME)
51-
@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
52+
@Target(ElementType.TYPE)
5253
@StableAPI(since = "0.6.0")
5354
public @interface StableAPI {
5455
/**
5556
* The version this API was introduced/stabilized in. Used for library version tracking.
5657
*/
57-
@StableAPI(since = "0.6.0") String since();
58+
@StableAPI.Expose
59+
String since();
5860

5961
/**
6062
* You may use this annotation if you want a member to have an equal effective {@link #since()} value as its owner
6163
* class.
6264
* <p>
6365
* Everything else from the {@link StableAPI} class still applies, this is only here for brevity's sake.
64-
* Note that if you add a new field in a version newer than the class, you must use {@link StableAPI} with the
65-
* correct version!
66+
* Note that if you add a method/field in a version newer than the class, you must also specify the correct version!
6667
* <p>
6768
* Also note that this only works for class members (methods and fields),
6869
* inner classes still need to use {@link StableAPI}.
6970
*/
7071
@Documented
7172
@Retention(RetentionPolicy.RUNTIME)
72-
@Target(value = {ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
73+
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
7374
@StableAPI(since = "0.10.0")
74-
@interface Expose {}
75+
@interface Expose {
76+
@StableAPI.Expose
77+
String since() default "__PARENT__";
78+
}
7579

7680
/**
7781
* Use this if you want to explicitly mark specific members of a {@link StableAPI} class as internal-use only.
@@ -81,7 +85,7 @@
8185
*/
8286
@Documented
8387
@Retention(RetentionPolicy.RUNTIME)
84-
@Target(value = {ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
88+
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
8589
@StableAPI(since = "0.10.0")
8690
@interface Internal {}
8791
}

src/main/java/com/falsepattern/lib/config/ConfigurationManager.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
@StableAPI(since = "0.6.0")
4444
public class ConfigurationManager {
4545

46-
@StableAPI(since = "0.10.0")
46+
@StableAPI.Expose(since = "0.10.0")
4747
public static void initialize(Class<?>... configClasses) throws ConfigException {
4848
initialize((a, b) -> {}, configClasses);
4949
}
5050

51-
@StableAPI(since = "0.10.0")
51+
@StableAPI.Expose(since = "0.10.0")
5252
public static void initialize(BiConsumer<Class<?>, Field> validatorErrorCallback, Class<?>... configClasses)
5353
throws ConfigException {
5454
for (val clazz : configClasses) {
@@ -59,12 +59,12 @@ public static void initialize(BiConsumer<Class<?>, Field> validatorErrorCallback
5959
}
6060
}
6161

62-
@StableAPI(since = "0.10.0")
62+
@StableAPI.Expose(since = "0.10.0")
6363
public static boolean validate(boolean resetInvalid, Class<?>... configClasses) throws ConfigException {
6464
return validate((x, y) -> {}, resetInvalid, configClasses);
6565
}
6666

67-
@StableAPI(since = "0.10.0")
67+
@StableAPI.Expose(since = "0.10.0")
6868
public static boolean validate(BiConsumer<Class<?>, Field> validatorErrorCallback, boolean resetInvalid, Class<?>... configClasses)
6969
throws ConfigException {
7070
boolean valid = true;
@@ -74,14 +74,14 @@ public static boolean validate(BiConsumer<Class<?>, Field> validatorErrorCallbac
7474
return valid;
7575
}
7676

77-
@StableAPI(since = "0.10.0")
77+
@StableAPI.Expose(since = "0.10.0")
7878
public static void loadFromFile(Class<?>... configClasses) throws ConfigException {
7979
for (val clazz : configClasses) {
8080
ConfigurationManagerImpl.load(clazz);
8181
}
8282
}
8383

84-
@StableAPI(since = "0.10.0")
84+
@StableAPI.Expose(since = "0.10.0")
8585
public static void saveToFile(boolean validateAndResetInvalid, Class<?>... configClasses) throws ConfigException {
8686
for (val clazz : configClasses) {
8787
if (validateAndResetInvalid) {
@@ -127,7 +127,7 @@ public static List<IConfigElement> getConfigElements(Class<?> configClass) throw
127127
* @return The configuration elements.
128128
*/
129129
@SuppressWarnings("rawtypes")
130-
@StableAPI(since = "0.10.0")
130+
@StableAPI.Expose(since = "0.10.0")
131131
public static List<IConfigElement> getConfigElementsMulti(Class<?>... configClasses) throws ConfigException {
132132
switch (configClasses.length) {
133133
case 0:

src/main/java/com/falsepattern/lib/config/SimpleGuiConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public SimpleGuiConfig(GuiScreen parent, Class<?> configClass, String modID, Str
3737
this(parent, modID, modName, configClass);
3838
}
3939

40-
@StableAPI(since = "0.10.0")
40+
@StableAPI.Expose(since = "0.10.0")
4141
public SimpleGuiConfig(GuiScreen parent, String modID, String modName, Class<?>... configClasses)
4242
throws ConfigException {
4343
super(parent, ConfigurationManager.getConfigElementsMulti(configClasses), modID, false, false,

src/main/java/com/falsepattern/lib/toasts/SimpleToast.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ public int height() {
115115
return background.getIcon().getIconHeight();
116116
}
117117

118-
@StableAPI(since = "0.10.0")
118+
@StableAPI.Expose
119119
public void hide() {
120120
visibility = IToast.Visibility.HIDE;
121121
}
122122

123-
@StableAPI(since = "0.10.0")
123+
@StableAPI.Expose
124124
public void setProgress(float progress) {
125125
this.currentProgress = progress;
126126
}

src/main/java/com/falsepattern/lib/util/RenderUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private static Timer getMinecraftTimer() {
4949
return (Timer) timerField.get(getMinecraft());
5050
}
5151

52-
@StableAPI(since = "0.10.0")
52+
@StableAPI.Expose(since = "0.10.0")
5353
public static IIcon getFullTextureIcon(String iconName, int width, int height) {
5454
return new IIcon() {
5555
@Override

0 commit comments

Comments
 (0)