2 minutes estimated read time

Config

Below is an example for a YAML and a Properties config.
YAML configs can be used to store more complex data, like your custom classes for other constructs.

Property configs can only store simple data like strings, booleans, numbers, etc.

MyYamlConfig.java
@VitalConfig.Info(name = "myconfig.yaml", processor = VitalYAMLConfigProcessor.class)
public class MyYamlConfig extends VitalConfig {
    @Property(types = {String.class})
    private String myString;

    // You always have to explicitly define the generic parameters here 
    @Property(types = {String.class})
    private List<String> myStringList;

    @Property(types = {MyClass.class})
    private MyClass myClass;

    @Property(types = {String.class, MyClass.class})
    private Map<String, MyClass> myClassMap;

    // Getters and setters

    public class MyClass {
        @Property(types = {String.class})
        private String myClassString;

        // Custom config objects must have a default constructor
        public MyClass() {}

        // Getters and setters
    }
}
MyPropertiesConfig.java
@VitalConfig.Info(name = "myconfig.properties", processor = VitalPropertiesConfigProcessor.class)
public class MyPropertiesConfig extends VitalConfig {
    @Property(types = {String.class})
    private String myString;

    @Property(types = {Boolean.class})
    private boolean myBoolean;

    @Property(types = {Integer.class})
    private int myInt;

    // Getters and setters
}

Found an issue?

Help us improve the documentation by reporting typos, missing information, or anything confusing.

Don't worry, we will auto-fill most of the annoying fields.

Create GitHub issue

This site and the Vital framework were built with ❤️ by Mike Neumann