#347 Add 'contains' method to PropertyType
This commit is contained in:
@@ -33,6 +33,12 @@ class EnumPropertyType<E extends Enum<E>> extends PropertyType<E> {
|
||||
return asList("'" + value + "'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Property<E> property, YamlConfiguration configuration) {
|
||||
return super.contains(property, configuration)
|
||||
&& mapToEnum(configuration.getString(property.getPath())) != null;
|
||||
}
|
||||
|
||||
private E mapToEnum(String value) {
|
||||
for (E entry : clazz.getEnumConstants()) {
|
||||
if (entry.name().equalsIgnoreCase(value)) {
|
||||
|
||||
@@ -49,6 +49,10 @@ 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.
|
||||
|
||||
Reference in New Issue
Block a user