Class FormatDetector
- java.lang.Object
-
- com.electronwill.nightconfig.core.file.FormatDetector
-
public final class FormatDetector extends java.lang.ObjectUtility class for detecting the format of configurations files.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ConfigFormat<?>detect(java.io.File file)Detects the ConfigFormat of a file.static ConfigFormat<?>detect(java.nio.file.Path file)Detects the ConfigFormat of a file.static ConfigFormat<?>detectByName(java.lang.String fileName)Detects the ConfigFormat of a filename.static voidregisterExtension(java.lang.String fileExtension, ConfigFormat<?> format)Registers a ConfigFormat for a specific fileExtension.static voidregisterExtension(java.lang.String fileExtension, java.util.function.Supplier<ConfigFormat<?>> formatSupplier)Registers a ConfigFormat's supplier for a specific fileExtension.
-
-
-
Method Detail
-
registerExtension
public static void registerExtension(java.lang.String fileExtension, ConfigFormat<?> format)Registers a ConfigFormat for a specific fileExtension.- Parameters:
fileExtension- the file extensionformat- the config format
-
registerExtension
public static void registerExtension(java.lang.String fileExtension, java.util.function.Supplier<ConfigFormat<?>> formatSupplier)Registers a ConfigFormat's supplier for a specific fileExtension.- Parameters:
fileExtension- the file extensionformatSupplier- the Supplier of the config format
-
detect
public static ConfigFormat<?> detect(java.io.File file)
Detects the ConfigFormat of a file.- Parameters:
file- the file- Returns:
- the associated ConfigFormat, or null if not found
-
detect
public static ConfigFormat<?> detect(java.nio.file.Path file)
Detects the ConfigFormat of a file.- Parameters:
file- the file- Returns:
- the associated ConfigFormat, or null if not found
-
detectByName
public static ConfigFormat<?> detectByName(java.lang.String fileName)
Detects the ConfigFormat of a filename.- Parameters:
fileName- the file name- Returns:
- the associated ConfigFormat, or null if not found
-
-