
com.electronwill.nightconfig.core.SimpleCommentedConfig Maven / Gradle / Ivy
package com.electronwill.nightconfig.core;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Supplier;
/**
* Default concrete implementation of CommentedConfig. The values are stored in a map, generally a
* HashMap, or a ConcurrentHashMap if the config is concurrent.
*
* @author TheElectronWill
*/
final class SimpleCommentedConfig extends AbstractCommentedConfig {
private final ConfigFormat> configFormat;
/**
* Creates a SimpleCommentedConfig with the specified format.
*
* @param configFormat the config's format
*/
SimpleCommentedConfig(ConfigFormat> configFormat, boolean concurrent) {
super(concurrent ? new ConcurrentHashMap<>() : new HashMap<>());
this.configFormat = configFormat;
}
/**
* Creates a SimpleCommentedConfig with the specified data and format. The map is used as it is and
* isn't copied.
*/
SimpleCommentedConfig(Map valueMap, ConfigFormat> configFormat) {
super(valueMap);
this.configFormat = configFormat;
}
/**
* Creates a SimpleCommentedConfig with the specified backing map supplier and format.
*
* @param mapCreator the supplier for backing maps
* @param configFormat the config's format
*/
SimpleCommentedConfig(Supplier
© 2015 - 2025 Weber Informatics LLC | Privacy Policy