Skip to content

Instantly share code, notes, and snippets.

@Jezza
Created November 28, 2014 09:47
Show Gist options
  • Save Jezza/bb91cbc4379f7ed3d9ca to your computer and use it in GitHub Desktop.
Save Jezza/bb91cbc4379f7ed3d9ca to your computer and use it in GitHub Desktop.
package me.jezza.oc.api.configuration;
import java.lang.annotation.*;
public class Config {
public static final Class[] VALID_CONFIG_ANNOTATIONS = new Class[]{
ConfigBoolean.class,
ConfigBooleanArray.class,
ConfigInteger.class,
ConfigIntegerArray.class,
ConfigFloat.class,
ConfigFloatArray.class,
ConfigDouble.class,
ConfigDoubleArray.class,
ConfigString.class,
ConfigStringArray.class,
};
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public static @interface ConfigBoolean {
String category();
String key();
boolean defaultValue();
String comment() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public static @interface ConfigBooleanArray {
String category();
String key();
boolean[] defaultValue();
boolean isListLengthFixed() default false;
int maxListLength() default -1;
String comment() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public static @interface ConfigInteger {
String category();
String key();
int defaultValue();
int minValue() default Integer.MIN_VALUE;
int maxValue() default Integer.MAX_VALUE;
String comment() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public static @interface ConfigIntegerArray {
String category();
String key();
int[] defaultValues();
boolean isListLengthFixed() default false;
int maxListLength() default -1;
String comment() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public static @interface ConfigFloat {
String category();
String key();
float defaultValue();
float minValue() default Float.MIN_VALUE;
float maxValue() default Float.MAX_VALUE;
String comment() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public static @interface ConfigFloatArray {
String category();
String key();
float[] defaultArray();
boolean isListLengthFixed() default false;
int maxListLength() default -1;
String comment() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public static @interface ConfigDouble {
String category();
String key();
double defaultValue();
double minValue() default Double.MIN_VALUE;
double maxValue() default Double.MAX_VALUE;
String comment() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public static @interface ConfigDoubleArray {
String category();
String key();
double[] defaultArray();
boolean isListLengthFixed() default false;
int maxListLength() default -1;
String comment() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public static @interface ConfigString {
String category();
String key();
String defaultValue();
String comment() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public static @interface ConfigStringArray {
String category();
String key();
String[] defaultArray() default {};
boolean isListLengthFixed() default false;
int maxListLength() default -1;
String comment() default "";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment