Interface ConfigSource

All Known Implementing Classes:
ConfigSource.FileConfigSource, ConfigSource.ResourceConfigSource

public interface ConfigSource
Represents a configuration source (file, resource, or other stream-based source).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    File-based configuration source implementation.
    static class 
    Classpath resource configuration source implementation.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if this source exists.
    static @NotNull ConfigSource
    file(@NotNull File file)
    Creates a file-based configuration source.
    static @NotNull ConfigSource
    file(@NotNull Path path)
    Creates a file-based configuration source.
    @NotNull String
    Gets the name of this source (for display/logging purposes).
    @NotNull InputStream
    Opens an input stream to read the configuration.
    @NotNull OutputStream
    Opens an output stream to write the configuration.
    @Nullable Path
    Gets the file path for file-based sources.
    static @NotNull ConfigSource
    resource(@NotNull ClassLoader loader, @NotNull String path)
    Creates a classpath resource configuration source.
  • Method Details

    • openRead

      @NotNull @NotNull InputStream openRead() throws IOException
      Opens an input stream to read the configuration.
      Returns:
      the input stream
      Throws:
      IOException - if the stream cannot be opened
    • openWrite

      @NotNull @NotNull OutputStream openWrite() throws IOException
      Opens an output stream to write the configuration.
      Returns:
      the output stream
      Throws:
      IOException - if the stream cannot be opened
    • exists

      boolean exists()
      Checks if this source exists.
      Returns:
      true if the source exists and can be read
    • name

      @NotNull @NotNull String name()
      Gets the name of this source (for display/logging purposes).
      Returns:
      the source name
    • path

      @Nullable @Nullable Path path()
      Gets the file path for file-based sources.
      Returns:
      the path, or null if not file-based
    • file

      @NotNull static @NotNull ConfigSource file(@NotNull @NotNull Path path)
      Creates a file-based configuration source.
      Parameters:
      path - the file path
      Returns:
      a new ConfigSource
    • file

      @NotNull static @NotNull ConfigSource file(@NotNull @NotNull File file)
      Creates a file-based configuration source.
      Parameters:
      file - the file
      Returns:
      a new ConfigSource
    • resource

      @NotNull static @NotNull ConfigSource resource(@NotNull @NotNull ClassLoader loader, @NotNull @NotNull String path)
      Creates a classpath resource configuration source.
      Parameters:
      loader - the class loader to use
      path - the resource path
      Returns:
      a new ConfigSource