#347 Create tests and add check for missing settings in NewSetting
This commit is contained in:
@@ -74,6 +74,16 @@ public class Property<T> {
|
||||
return type.asYaml(this, configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether or not the given configuration file contains the property.
|
||||
*
|
||||
* @param configuration The configuration file to verify
|
||||
* @return True if the property is present, false otherwise
|
||||
*/
|
||||
public boolean isPresent(YamlConfiguration configuration) {
|
||||
return type.contains(this, configuration);
|
||||
}
|
||||
|
||||
// -----
|
||||
// Trivial getters
|
||||
// -----
|
||||
|
||||
@@ -41,6 +41,17 @@ public abstract class PropertyType<T> {
|
||||
return asYaml(getFromFile(property, configuration));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the property is present in the given configuration.
|
||||
*
|
||||
* @param property The property to search for
|
||||
* @param configuration The configuration to verify
|
||||
* @return True if the property is present, false otherwise
|
||||
*/
|
||||
public boolean contains(Property<T> property, YamlConfiguration configuration) {
|
||||
return configuration.contains(property.getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the given value to YAML.
|
||||
*
|
||||
@@ -49,10 +60,6 @@ public abstract class PropertyType<T> {
|
||||
*/
|
||||
protected abstract List<String> asYaml(T value);
|
||||
|
||||
protected boolean contains(Property<T> property, YamlConfiguration configuration) {
|
||||
return configuration.contains(property.getPath());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Boolean property.
|
||||
@@ -145,6 +152,11 @@ public abstract class PropertyType<T> {
|
||||
}
|
||||
return resultLines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Property<List<String>> property, YamlConfiguration configuration) {
|
||||
return configuration.contains(property.getPath()) && configuration.isList(property.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user