JavaDoc added

dev
Exlll 8 years ago
parent 3bf8e64d93
commit e7ce5ad632

@ -5,6 +5,11 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* The {@code Comment} annotation can be used to add comments to a configuration file.
* <p>
* Each {@code String} is written into a new line.
*/
@Target({ElementType.TYPE, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Comment {

@ -2,6 +2,7 @@ package de.exlll.configlib;
import org.yaml.snakeyaml.parser.ParserException;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
@ -14,6 +15,14 @@ public abstract class Configuration {
private final FieldMapper fieldMapper;
private final ConfigurationWriter writer;
/**
* Creates a new {@code Configuration} instance.
*
* You can use {@link File#toPath()} to obtain a {@link Path} object from a {@link File}.
*
* @param configPath location of the configuration file
* @throws NullPointerException if {@code configPath} is null
*/
public Configuration(Path configPath) {
Objects.requireNonNull(configPath);
@ -40,11 +49,11 @@ public abstract class Configuration {
}
/**
* Saves {@code this} fields and {@code @Comment} annotations to a configuration file at the specified {@code Path}.
* Saves this instance and its {@code @Comment} annotations to a configuration file at the specified {@code Path}.
* <p>
* Fields which are {@code final}, {@code static} or {@code transient} are ignored.
* Fields which are {@code final}, {@code static} or {@code transient} are not saved.
* <p>
* If the file exists, it is overriden; otherwise, it is created.
* If the file exists, it is overridden; otherwise, it is created.
*
* @throws IOException if an I/O error occurs when saving the configuration file.
* @throws ParserException if invalid YAML

@ -1,7 +1,7 @@
# ConfigLib
This library facilitates the creation, saving and loading of YAML configuration files. It does so
by using Reflection on configuration classes and automatically saving and loading their fields,
creating the configuration file and its parent directories if neccessary.
creating the configuration file and its parent directories if necessary.
## Features
- automatic creation, saving and loading of YAML configurations
@ -18,9 +18,9 @@ added to this class and which are not `final`, `static` or `transient` can autom
##### Saving and loading a configuration
Instances of your configuration class have a `load`, `save` and `loadAndSave` method:
- `save` dumps all fields which are not `final`, `static` or `transient` to a configuration file.
If the file exists, it is overriden; otherwise, it is created.
- `load` reads the configuration file and updates the instance's values.
- `loadAndSave` loads the configuration file and then calls `save` to update the file's values.
If the file exists, it is overridden; otherwise, it is created.
- `load` reads the configuration file and updates the instance's field values.
- `loadAndSave` loads the configuration file and then calls `save` to update the file.
If the file doesn't exist, it is saved.
##### Adding and removing fields

Loading…
Cancel
Save