PlotSquared/src/main/java/com/intellectualcrafters/configuration/ConfigurationOptions.java

98 lines
2.9 KiB
Java
Raw Normal View History

2015-07-05 12:51:34 +02:00
package com.intellectualcrafters.configuration;
/**
* Various settings for controlling the input and output of a {@link
* Configuration}
*/
2015-09-11 12:09:22 +02:00
public class ConfigurationOptions
{
2015-07-05 12:51:34 +02:00
private char pathSeparator = '.';
private boolean copyDefaults = false;
private final Configuration configuration;
2015-09-11 12:09:22 +02:00
protected ConfigurationOptions(final Configuration configuration)
{
2015-07-05 12:51:34 +02:00
this.configuration = configuration;
}
/**
* Returns the {@link Configuration} that this object is responsible for.
*
* @return Parent configuration
*/
2015-09-11 12:09:22 +02:00
public Configuration configuration()
{
2015-07-05 12:51:34 +02:00
return configuration;
}
/**
* Gets the char that will be used to separate {@link
* ConfigurationSection}s
* <p>
* This value does not affect how the {@link Configuration} is stored,
* only in how you access the data. The default value is '.'.
*
* @return Path separator
*/
2015-09-11 12:09:22 +02:00
public char pathSeparator()
{
2015-07-05 12:51:34 +02:00
return pathSeparator;
}
/**
* Sets the char that will be used to separate {@link
* ConfigurationSection}s
* <p>
* This value does not affect how the {@link Configuration} is stored,
* only in how you access the data. The default value is '.'.
*
* @param value Path separator
* @return This object, for chaining
*/
2015-09-11 12:09:22 +02:00
public ConfigurationOptions pathSeparator(final char value)
{
pathSeparator = value;
2015-07-05 12:51:34 +02:00
return this;
}
/**
* Checks if the {@link Configuration} should copy values from its default
* {@link Configuration} directly.
* <p>
* If this is true, all values in the default Configuration will be
* directly copied, making it impossible to distinguish between values
* that were set and values that are provided by default. As a result,
* {@link ConfigurationSection#contains(java.lang.String)} will always
* return the same value as {@link
* ConfigurationSection#isSet(java.lang.String)}. The default value is
* false.
*
* @return Whether or not defaults are directly copied
*/
2015-09-11 12:09:22 +02:00
public boolean copyDefaults()
{
2015-07-05 12:51:34 +02:00
return copyDefaults;
}
/**
* Sets if the {@link Configuration} should copy values from its default
* {@link Configuration} directly.
* <p>
* If this is true, all values in the default Configuration will be
* directly copied, making it impossible to distinguish between values
* that were set and values that are provided by default. As a result,
* {@link ConfigurationSection#contains(java.lang.String)} will always
* return the same value as {@link
* ConfigurationSection#isSet(java.lang.String)}. The default value is
* false.
*
* @param value Whether or not defaults are directly copied
* @return This object, for chaining
*/
2015-09-11 12:09:22 +02:00
public ConfigurationOptions copyDefaults(final boolean value)
{
copyDefaults = value;
2015-07-05 12:51:34 +02:00
return this;
}
}