2015-07-05 12:51:34 +02:00
|
|
|
package com.intellectualcrafters.configuration;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents a source of configurable options and settings
|
|
|
|
*/
|
2015-09-13 06:04:31 +02:00
|
|
|
public interface Configuration extends ConfigurationSection {
|
2015-07-05 12:51:34 +02:00
|
|
|
/**
|
|
|
|
* Sets the default value of the given path as provided.
|
|
|
|
* <p>
|
|
|
|
* If no source {@link Configuration} was provided as a default
|
|
|
|
* collection, then a new {@link MemoryConfiguration} will be created to
|
|
|
|
* hold the new default value.
|
|
|
|
* <p>
|
|
|
|
* If value is null, the value will be removed from the default
|
|
|
|
* Configuration source.
|
|
|
|
*
|
|
|
|
* @param path Path of the value to set.
|
|
|
|
* @param value Value to set the default to.
|
|
|
|
* @throws IllegalArgumentException Thrown if path is null.
|
|
|
|
*/
|
2015-09-11 12:09:22 +02:00
|
|
|
@Override
|
|
|
|
public void addDefault(final String path, final Object value);
|
2015-09-13 06:04:31 +02:00
|
|
|
|
2015-07-05 12:51:34 +02:00
|
|
|
/**
|
|
|
|
* Sets the default values of the given paths as provided.
|
|
|
|
* <p>
|
|
|
|
* If no source {@link Configuration} was provided as a default
|
|
|
|
* collection, then a new {@link MemoryConfiguration} will be created to
|
|
|
|
* hold the new default values.
|
|
|
|
*
|
|
|
|
* @param defaults A map of Path->Values to add to defaults.
|
|
|
|
* @throws IllegalArgumentException Thrown if defaults is null.
|
|
|
|
*/
|
2015-09-11 12:09:22 +02:00
|
|
|
public void addDefaults(final Map<String, Object> defaults);
|
2015-09-13 06:04:31 +02:00
|
|
|
|
2015-07-05 12:51:34 +02:00
|
|
|
/**
|
|
|
|
* Sets the default values of the given paths as provided.
|
|
|
|
* <p>
|
|
|
|
* If no source {@link Configuration} was provided as a default
|
|
|
|
* collection, then a new {@link MemoryConfiguration} will be created to
|
|
|
|
* hold the new default value.
|
|
|
|
* <p>
|
|
|
|
* This method will not hold a reference to the specified Configuration,
|
|
|
|
* nor will it automatically update if that Configuration ever changes. If
|
|
|
|
* you require this, you should set the default source with {@link
|
|
|
|
* #setDefaults(com.intellectualcrafters.configuration.Configuration)}.
|
|
|
|
*
|
|
|
|
* @param defaults A configuration holding a list of defaults to copy.
|
|
|
|
* @throws IllegalArgumentException Thrown if defaults is null or this.
|
|
|
|
*/
|
2015-09-11 12:09:22 +02:00
|
|
|
public void addDefaults(final Configuration defaults);
|
2015-09-13 06:04:31 +02:00
|
|
|
|
2015-07-05 12:51:34 +02:00
|
|
|
/**
|
|
|
|
* Sets the source of all default values for this {@link Configuration}.
|
|
|
|
* <p>
|
|
|
|
* If a previous source was set, or previous default values were defined,
|
|
|
|
* then they will not be copied to the new source.
|
|
|
|
*
|
|
|
|
* @param defaults New source of default values for this configuration.
|
|
|
|
* @throws IllegalArgumentException Thrown if defaults is null or this.
|
|
|
|
*/
|
2015-09-11 12:09:22 +02:00
|
|
|
public void setDefaults(final Configuration defaults);
|
2015-09-13 06:04:31 +02:00
|
|
|
|
2015-07-05 12:51:34 +02:00
|
|
|
/**
|
|
|
|
* Gets the source {@link Configuration} for this configuration.
|
|
|
|
* <p>
|
|
|
|
* If no configuration source was set, but default values were added, then
|
|
|
|
* a {@link MemoryConfiguration} will be returned. If no source was set
|
|
|
|
* and no defaults were set, then this method will return null.
|
|
|
|
*
|
|
|
|
* @return Configuration source for default values, or null if none exist.
|
|
|
|
*/
|
|
|
|
public Configuration getDefaults();
|
2015-09-13 06:04:31 +02:00
|
|
|
|
2015-07-05 12:51:34 +02:00
|
|
|
/**
|
|
|
|
* Gets the {@link ConfigurationOptions} for this {@link Configuration}.
|
|
|
|
* <p>
|
|
|
|
* All setters through this method are chainable.
|
|
|
|
*
|
|
|
|
* @return Options for this configuration
|
|
|
|
*/
|
|
|
|
public ConfigurationOptions options();
|
|
|
|
}
|