Ver código fonte

Restructure bounded annotations

Lortseam 4 anos atrás
pai
commit
66362b26ef

+ 8 - 8
src/main/java/me/lortseam/completeconfig/ConfigManager.java

@@ -145,29 +145,29 @@ public class ConfigManager {
                     }
                     builder.setForceUpdate(entryAnnotation.forceUpdate());
                 }
-                if (field.isAnnotationPresent(ConfigEntry.Integer.Bounded.class)) {
+                if (field.isAnnotationPresent(ConfigEntry.Bounded.Integer.class)) {
                     if (field.getType() != int.class && field.getType() != Integer.class) {
                         throw new IllegalAnnotationTargetException("Cannot apply Integer bound to non Integer field " + field);
                     }
-                    ConfigEntry.Integer.Bounded bounds = field.getDeclaredAnnotation(ConfigEntry.Integer.Bounded.class);
+                    ConfigEntry.Bounded.Integer bounds = field.getDeclaredAnnotation(ConfigEntry.Bounded.Integer.class);
                     builder.setBounds(bounds.min(), bounds.max());
-                } else if (field.isAnnotationPresent(ConfigEntry.Long.Bounded.class)) {
+                } else if (field.isAnnotationPresent(ConfigEntry.Bounded.Long.class)) {
                     if (field.getType() != long.class && field.getType() != Long.class) {
                         throw new IllegalAnnotationTargetException("Cannot apply Long bound to non Long field " + field);
                     }
-                    ConfigEntry.Long.Bounded bounds = field.getDeclaredAnnotation(ConfigEntry.Long.Bounded.class);
+                    ConfigEntry.Bounded.Long bounds = field.getDeclaredAnnotation(ConfigEntry.Bounded.Long.class);
                     builder.setBounds(bounds.min(), bounds.max());
-                } else if (field.isAnnotationPresent(ConfigEntry.Float.Bounded.class)) {
+                } else if (field.isAnnotationPresent(ConfigEntry.Bounded.Float.class)) {
                     if (field.getType() != float.class && field.getType() != Float.class) {
                         throw new IllegalAnnotationTargetException("Cannot apply Float bound to non Float field " + field);
                     }
-                    ConfigEntry.Float.Bounded bounds = field.getDeclaredAnnotation(ConfigEntry.Float.Bounded.class);
+                    ConfigEntry.Bounded.Float bounds = field.getDeclaredAnnotation(ConfigEntry.Bounded.Float.class);
                     builder.setBounds(bounds.min(), bounds.max());
-                } else if (field.isAnnotationPresent(ConfigEntry.Double.Bounded.class)) {
+                } else if (field.isAnnotationPresent(ConfigEntry.Bounded.Double.class)) {
                     if (field.getType() != double.class && field.getType() != Double.class) {
                         throw new IllegalAnnotationTargetException("Cannot apply Double bound to non Double field " + field);
                     }
-                    ConfigEntry.Double.Bounded bounds = field.getDeclaredAnnotation(ConfigEntry.Double.Bounded.class);
+                    ConfigEntry.Bounded.Double bounds = field.getDeclaredAnnotation(ConfigEntry.Bounded.Double.class);
                     builder.setBounds(bounds.min(), bounds.max());
                 }
                 Entry<?> entry = builder.build();

+ 5 - 20
src/main/java/me/lortseam/completeconfig/api/ConfigEntry.java

@@ -19,11 +19,11 @@ public @interface ConfigEntry {
     boolean forceUpdate() default false;
 
     @NoArgsConstructor(access = AccessLevel.PRIVATE)
-    class Integer {
+    class Bounded {
 
         @Target(ElementType.FIELD)
         @Retention(RetentionPolicy.RUNTIME)
-        public @interface Bounded {
+        public @interface Integer {
 
             int min() default java.lang.Integer.MIN_VALUE;
 
@@ -31,14 +31,9 @@ public @interface ConfigEntry {
 
         }
 
-    }
-
-    @NoArgsConstructor(access = AccessLevel.PRIVATE)
-    class Long {
-
         @Target(ElementType.FIELD)
         @Retention(RetentionPolicy.RUNTIME)
-        public @interface Bounded {
+        public @interface Long {
 
             long min() default java.lang.Long.MIN_VALUE;
 
@@ -46,14 +41,9 @@ public @interface ConfigEntry {
 
         }
 
-    }
-
-    @NoArgsConstructor(access = AccessLevel.PRIVATE)
-    class Float {
-
         @Target(ElementType.FIELD)
         @Retention(RetentionPolicy.RUNTIME)
-        public @interface Bounded {
+        public @interface Float {
 
             float min() default -java.lang.Float.MAX_VALUE;
 
@@ -61,14 +51,9 @@ public @interface ConfigEntry {
 
         }
 
-    }
-
-    @NoArgsConstructor(access = AccessLevel.PRIVATE)
-    class Double {
-
         @Target(ElementType.FIELD)
         @Retention(RetentionPolicy.RUNTIME)
-        public @interface Bounded {
+        public @interface Double {
 
             double min() default -java.lang.Double.MAX_VALUE;