initial commit

This commit is contained in:
00asdf 2023-03-29 03:15:42 +02:00
commit 3353b4deb7
13 changed files with 622 additions and 0 deletions

29
.gitignore vendored Normal file
View File

@ -0,0 +1,29 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,8 @@
<component name="ArtifactManager">
<artifact type="jar" name="Confidibus:jar">
<output-path>$PROJECT_DIR$/out/artifacts/Confidibus_jar</output-path>
<root id="archive" name="Confidibus.jar">
<element id="module-output" name="Confidibus" />
</root>
</artifact>
</component>

6
.idea/misc.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="graalvm-ce-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Confidibus.iml" filepath="$PROJECT_DIR$/Confidibus.iml" />
</modules>
</component>
</project>

124
.idea/uiDesigner.xml Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

93
.idea/workspace.xml Normal file
View File

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="d8897652-66f5-4f30-9dbf-a6b280944ebf" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Confidibus.iml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/dev/asdf00/confidibus/Confidibus.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/dev/asdf00/confidibus/ConfigurationException.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/dev/asdf00/confidibus/annotations/Config.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/dev/asdf00/confidibus/annotations/Section.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/dev/asdf00/confidibus/annotations/Value.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="AnnotationType" />
<option value="Class" />
</list>
</option>
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="2Nek6WahBl2H710lzKATuocLQOx" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"project.structure.last.edited": "Artifacts",
"project.structure.proportion": "0.0",
"project.structure.side.proportion": "0.2"
}
}]]></component>
<component name="RecentsManager">
<key name="MoveClassesOrPackagesDialog.RECENTS_KEY">
<recent name="dev.asdf00.confidibus.config" />
<recent name="dev.asdf00.confidibus" />
</key>
</component>
<component name="RunManager">
<configuration name="MainTest" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="dev.asdf00.confidibus.Main" />
<module name="Confidibus" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="d8897652-66f5-4f30-9dbf-a6b280944ebf" name="Changes" comment="" />
<created>1680031761802</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1680031761802</updated>
</task>
<servers />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/dev/asdf00/confidibus/Confidibus.java</url>
<line>180</line>
<option name="timeStamp" value="3" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/dev/asdf00/confidibus/Confidibus.java</url>
<line>252</line>
<option name="timeStamp" value="4" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>

11
Confidibus.iml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,279 @@
package dev.asdf00.confidibus;
import dev.asdf00.confidibus.annotations.Config;
import dev.asdf00.confidibus.annotations.Section;
import dev.asdf00.confidibus.annotations.Value;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
/**
* Helper class to initialize and read a configuration file. Call {@code init()} to parse the configuration file.
* <br/>
* The {@code configClass} needs to be annotated with @Config and @Section. It may contain inner classes annotated
* with @Section. Every value needs to be public, static and annotated with @Value.
* <br/>
* This config only allows primitive types and strings.
*/
public class Confidibus {
private final Class<?> _class;
private final PrintStream _debug;
private StringBuilder sb = new StringBuilder();
private int indent = 0;
private Confidibus(Class<?> configClass, PrintStream debugMsgStream) {
_class = configClass;
_debug = debugMsgStream;
}
/**
* Creates helper instance.
* @param configClass class containing the annotations for a config
* @param debugMsgStream {@link PrintStream} where debug output shall be written to.
* Can be {@code null} if no debug output should be written
*/
public static Confidibus of(Class<?> configClass, PrintStream debugMsgStream) {
return new Confidibus(configClass, debugMsgStream);
}
/**
* Initialize values in {@code configClass}.
* @param createIfMissing permission to create new config file if none is found
*/
public void init(boolean createIfMissing) {
Config cAnn = _class.getAnnotation(Config.class);
if (cAnn == null) {
throw new ConfigurationException("missing @Config annotation for %s!", _class.getSimpleName());
}
Section cSect = _class.getAnnotation(Section.class);
if (cSect == null) {
throw new ConfigurationException("missing @Section annotation for %s!", _class.getSimpleName());
}
Path cPath = Path.of(cAnn.path());
if (Files.exists(cPath)) {
printDebug("found config file at %s!", cPath.toString());
try {
parseFile(Files.readAllLines(cPath).iterator(), parseConfigClass(_class), true);
} catch (IOException e) {
throw new ConfigurationException("error reading %s!", cPath.toString());
}
} else if (createIfMissing) {
printDebug("creating new config file at %s!", cPath.toString());
try {
Files.writeString(cPath, initNewSection(_class).toString(), StandardOpenOption.CREATE_NEW);
} catch (IOException e) {
throw new ConfigurationException(e, "error creating new config file!");
}
} else {
throw new ConfigurationException("did not find %s and was not allowed to create a new file!", cPath.toString());
}
}
private static <T> boolean setConfigValue(Field f, String v) {
if (!isValidConfigValue(f)) {
return false;
}
try {
if (f.getType().equals(byte.class)) {
f.set(null, Byte.parseByte(v));
} else if (f.getType().equals(short.class)) {
f.set(null, Short.parseShort(v));
} else if (f.getType().equals(int.class)) {
f.set(null, Integer.parseInt(v));
} else if (f.getType().equals(long.class)) {
f.set(null, Long.parseLong(v));
} else if (f.getType().equals(float.class)) {
f.set(null, Float.parseFloat(v));
} else if (f.getType().equals(double.class)) {
f.set(null, Double.parseDouble(v));
} else if (f.getType().equals(boolean.class)) {
f.set(null, Boolean.parseBoolean(v));
} else if (f.getType().equals(char.class)) {
f.set(null, v.charAt(0));
} else if (f.getType().equals(String.class)) {
f.set(null, v);
} else {
return false;
}
return true;
} catch (IllegalAccessException | NumberFormatException | IndexOutOfBoundsException e) {
return false;
}
}
private static boolean isValidConfigValue(Field f) {
return f.getAnnotation(Value.class) != null && f.getAnnotation(Value.class).name().indexOf('\n') == -1 &&
f.getAnnotation(Value.class).name().indexOf(':') == -1 && Modifier.isStatic(f.getModifiers()) &&
!Modifier.isFinal(f.getModifiers()) && Modifier.isPublic(f.getModifiers()) &&
(f.getType().isPrimitive() || f.getType().equals(String.class));
}
private static boolean isValidSection(Class<?> c) {
Section s = c.getAnnotation(Section.class);
return s != null && s.title().indexOf('\n') == -1 && s.title().indexOf('{') == -1;
}
private StringBuilder initNewSection(Class<?> section) {
Section ann = section.getAnnotation(Section.class);
if (!ann.comment().equals("")) {
for (String line : ann.comment().split("\n")) {
sb.append(" ".repeat(indent)).append("// ").append(line).append('\n');
}
}
if (ann.title().indexOf('\n') != -1) {
throw new ConfigurationException("newline in title of section %s is not allowed!", section.getSimpleName());
}
sb.append(" ".repeat(indent)).append("[SECTION] ").append(ann.title()).append(" {\n");
printDebug("initialized section %s defined in class %s!", ann.title(), section.getSimpleName());
indent++;
boolean firstField = true;
for (Field f : section.getDeclaredFields()) {
Value v = f.getAnnotation(Value.class);
if (v != null) {
if (!isValidConfigValue(f)) {
throw new ConfigurationException("%s.%s is not applicable as a config value!", section.getSimpleName(), f.getName());
}
if (firstField) {
firstField = false;
} else {
sb.append('\n');
}
if (!v.comment().equals("")) {
for (String line : v.comment().split("\n")) {
sb.append(" ".repeat(indent)).append("// ").append(line).append('\n');
}
}
String name = v.name();
if (name.isEmpty()) {
name = f.getName();
}
String type = f.getType().equals(String.class) ? "String" : f.getType().getTypeName();
sb.append(" ".repeat(indent)).append('[').append(type).append("] ").append(name).append(": ")
.append(v._default()).append('\n');
setConfigValue(f, v._default());
printDebug("initialized %s(%s) with %s!", f.getName(), name, v._default());
}
}
for (Class<?> subSection : section.getDeclaredClasses()) {
Section subAnn = subSection.getAnnotation(Section.class);
if (subAnn != null) {
sb.append("\n\n");
initNewSection(subSection);
}
}
indent--;
sb.append(" ".repeat(indent)).append("}\n");
return sb;
}
private void parseFile(Iterator<String> file, CClass config, boolean first) {
boolean isOrigin = first;
boolean seenEnd = false;
while (file.hasNext()) {
String line = file.next();
int i;
for (i = 0; i < line.length(); i++) {
if (line.charAt(i) != ' ') {
break;
}
}
if (i < line.length()) {
line = line.substring(i);
}
if (line.startsWith("[SECTION] ")) {
if (first) {
first = false;
} else {
int idx = line.indexOf(" {");
if (idx == -1) {
throw new ConfigurationException("error reading line '%s'!", line);
}
String key = line.substring(10, idx);
if (!config.subSections.containsKey(key)) {
throw new ConfigurationException("section '%s' not found in class %s!", key, config.associatedClass.getSimpleName());
}
parseFile(file, config.subSections.get(key), false);
}
} else if (line.startsWith("[")) {
int idx0 = line.indexOf("] ");
if (idx0 == -1) {
throw new ConfigurationException("error on value '%s'!", line);
}
int idx1 = line.indexOf(": ");
if (idx1 == -1) {
throw new ConfigurationException("error on value '%s'!", line);
}
String name = line.substring(idx0 + 2, idx1);
if (!config.vals.containsKey(name)) {
throw new ConfigurationException("value '%s' not found in class!", name);
}
String val = line.substring(idx1 + 2);
if (!setConfigValue(config.vals.get(name), val)) {
throw new ConfigurationException("error parsing '%s' as %s!", val, config.vals.get(name).getType());
}
config.writtenFields.add(name);
} else if (line.startsWith("}")) {
seenEnd = true;
break;
}
}
if (isOrigin && !seenEnd) {
throw new ConfigurationException("missing '}'!");
}
for (String fname : config.vals.keySet()) {
if (!config.writtenFields.contains(fname)) {
throw new ConfigurationException("not all fields of %s were written!", config.associatedClass.getSimpleName());
}
}
}
private CClass parseConfigClass(Class<?> curClass) {
CClass config = new CClass(curClass);
for (Field f : curClass.getDeclaredFields()) {
if (isValidConfigValue(f)) {
Value v = f.getAnnotation(Value.class);
String name = v.name();
if (name.isEmpty()) {
name = f.getName();
}
config.vals.put(name, f);
}
}
for (Class<?> subClass : curClass.getDeclaredClasses()) {
if (isValidSection(subClass)) {
Section sect = subClass.getAnnotation(Section.class);
config.subSections.put(sect.title(), parseConfigClass(subClass));
}
}
return config;
}
private void printDebug(String format, Object... params) {
if (_debug == null) {
return;
}
_debug.printf("[Confidibus] " + format + "\n", params);
}
private static class CClass {
public final Class<?> associatedClass;
public final HashMap<String, Field> vals = new HashMap<>();
public final HashMap<String, CClass> subSections = new HashMap<>();
public final HashSet<String> writtenFields = new HashSet<>();
public CClass(Class<?> associatedClass) {
this.associatedClass = associatedClass;
}
}
}

View File

@ -0,0 +1,10 @@
package dev.asdf00.confidibus;
public class ConfigurationException extends RuntimeException {
public ConfigurationException(String format, Object... params) {
super(String.format(format, params));
}
public ConfigurationException(Throwable cause, String format, Object... params) {
super(String.format(format, params), cause);
}
}

View File

@ -0,0 +1,15 @@
package dev.asdf00.confidibus.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Config {
/**
* path of the configuration file
*/
String path();
}

View File

@ -0,0 +1,14 @@
package dev.asdf00.confidibus.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Section {
String title();
String comment() default "";
}

View File

@ -0,0 +1,19 @@
package dev.asdf00.confidibus.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Value {
String comment() default "";
/**
* name of the value in the configuration file, if not specified, the name of the field will be written to the file
*/
String name() default "";
String _default();
}