Class FormatDetector


  • public final class FormatDetector
    extends java.lang.Object
    Utility 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 void registerExtension​(java.lang.String fileExtension, ConfigFormat<?> format)
      Registers a ConfigFormat for a specific fileExtension.
      static void registerExtension​(java.lang.String fileExtension, java.util.function.Supplier<ConfigFormat<?>> formatSupplier)
      Registers a ConfigFormat's supplier for a specific fileExtension.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • registerExtension

        public static void registerExtension​(java.lang.String fileExtension,
                                             ConfigFormat<?> format)
        Registers a ConfigFormat for a specific fileExtension.
        Parameters:
        fileExtension - the file extension
        format - 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 extension
        formatSupplier - 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