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 ClassesModifier and TypeInterfaceDescriptionstatic classFile-based configuration source implementation.static classClasspath resource configuration source implementation. -
Method Summary
Modifier and TypeMethodDescriptionbooleanexists()Checks if this source exists.static @NotNull ConfigSourceCreates a file-based configuration source.static @NotNull ConfigSourceCreates a file-based configuration source.@NotNull Stringname()Gets the name of this source (for display/logging purposes).@NotNull InputStreamopenRead()Opens an input stream to read the configuration.@NotNull OutputStreamOpens an output stream to write the configuration.@Nullable Pathpath()Gets the file path for file-based sources.static @NotNull ConfigSourceresource(@NotNull ClassLoader loader, @NotNull String path) Creates a classpath resource configuration source.
-
Method Details
-
openRead
Opens an input stream to read the configuration.- Returns:
- the input stream
- Throws:
IOException- if the stream cannot be opened
-
openWrite
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
Gets the name of this source (for display/logging purposes).- Returns:
- the source name
-
path
Gets the file path for file-based sources.- Returns:
- the path, or null if not file-based
-
file
Creates a file-based configuration source.- Parameters:
path- the file path- Returns:
- a new ConfigSource
-
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 usepath- the resource path- Returns:
- a new ConfigSource
-