All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.electronwill.nightconfig.hocon.HoconFormat Maven / Gradle / Ivy

Go to download

Powerful, easy-to-use and multi-language configuration library for the JVM - hocon_android module

There is a newer version: 3.6.6
Show newest version
package com.electronwill.nightconfig.hocon;

import com.electronwill.nightconfig.core.CommentedConfig;
import com.electronwill.nightconfig.core.ConfigFormat;
import com.electronwill.nightconfig.core.file.FormatDetector;
import com.electronwill.nightconfig.core.io.ConfigParser;
import com.electronwill.nightconfig.core.io.ConfigWriter;

/**
 * Represents the Hocon config format.
 *
 * @author TheElectronWill
 */
public final class HoconFormat implements ConfigFormat {
	private static final HoconFormat INSTANCE = new HoconFormat();

	/**
	 * @return the unique instance of HoconFormat
	 */
	public static HoconFormat instance() {
		return INSTANCE;
	}

	/**
	 * @return a new config with the hocon format
	 */
	public static CommentedConfig newConfig() {
		return INSTANCE.createConfig();
	}

	/**
	 * @return a new thread-safe config with the hocon format
	 */
	public static CommentedConfig newConcurrentConfig() {
		return INSTANCE.createConfig();
	}

	static {
		FormatDetector.registerExtension("hocon", INSTANCE);
		FormatDetector.registerExtension("conf", INSTANCE);
	}

	private HoconFormat() {}

	@Override
	public ConfigWriter createWriter() {
		return new HoconWriter();
	}

	@Override
	public ConfigParser createParser() {
		return new HoconParser();
	}

	@Override
	public CommentedConfig createConfig() {
		return CommentedConfig.of(this);
	}

	@Override
	public CommentedConfig createConcurrentConfig() {
		return CommentedConfig.ofConcurrent(this);
	}

	@Override
	public boolean supportsComments() {
		return true;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy