001    package org.bukkit.configuration;
002    
003    import java.util.Map;
004    
005    /**
006     * Represents a source of configurable options and settings
007     */
008    public interface Configuration extends ConfigurationSection {
009        /**
010         * Sets the default value of the given path as provided.
011         * <p>
012         * If no source {@link Configuration} was provided as a default
013         * collection, then a new {@link MemoryConfiguration} will be created to
014         * hold the new default value.
015         * <p>
016         * If value is null, the value will be removed from the default
017         * Configuration source.
018         *
019         * @param path Path of the value to set.
020         * @param value Value to set the default to.
021         * @throws IllegalArgumentException Thrown if path is null.
022         */
023        public void addDefault(String path, Object value);
024    
025        /**
026         * Sets the default values of the given paths as provided.
027         * <p>
028         * If no source {@link Configuration} was provided as a default
029         * collection, then a new {@link MemoryConfiguration} will be created to
030         * hold the new default values.
031         *
032         * @param defaults A map of Path->Values to add to defaults.
033         * @throws IllegalArgumentException Thrown if defaults is null.
034         */
035        public void addDefaults(Map<String, Object> defaults);
036    
037        /**
038         * Sets the default values of the given paths as provided.
039         * <p>
040         * If no source {@link Configuration} was provided as a default
041         * collection, then a new {@link MemoryConfiguration} will be created to
042         * hold the new default value.
043         * <p>
044         * This method will not hold a reference to the specified Configuration,
045         * nor will it automatically update if that Configuration ever changes. If
046         * you require this, you should set the default source with {@link
047         * #setDefaults(org.bukkit.configuration.Configuration)}.
048         *
049         * @param defaults A configuration holding a list of defaults to copy.
050         * @throws IllegalArgumentException Thrown if defaults is null or this.
051         */
052        public void addDefaults(Configuration defaults);
053    
054        /**
055         * Sets the source of all default values for this {@link Configuration}.
056         * <p>
057         * If a previous source was set, or previous default values were defined,
058         * then they will not be copied to the new source.
059         *
060         * @param defaults New source of default values for this configuration.
061         * @throws IllegalArgumentException Thrown if defaults is null or this.
062         */
063        public void setDefaults(Configuration defaults);
064    
065        /**
066         * Gets the source {@link Configuration} for this configuration.
067         * <p>
068         * If no configuration source was set, but default values were added, then
069         * a {@link MemoryConfiguration} will be returned. If no source was set
070         * and no defaults were set, then this method will return null.
071         *
072         * @return Configuration source for default values, or null if none exist.
073         */
074        public Configuration getDefaults();
075    
076        /**
077         * Gets the {@link ConfigurationOptions} for this {@link Configuration}.
078         * <p>
079         * All setters through this method are chainable.
080         *
081         * @return Options for this configuration
082         */
083        public ConfigurationOptions options();
084    }