public final class Config
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static IConfig |
Defaults
Initializes specified class with default values if any.
|
| Modifier and Type | Method and Description |
|---|---|
static IConfig |
anyOf(IConfig... sources) |
static <T> T |
get(java.lang.Class<T> clazz)
Loads settings for specified interface.
|
static IMutableConfig |
track(java.lang.Class<?> clazz) |
static IMutableConfig |
track(java.io.File file) |
static IMutableConfig |
track(java.nio.file.Path file) |
static IMutableConfig |
track(java.lang.String resourceName) |
static IMutableConfig |
track(java.lang.String resourceName,
java.lang.ClassLoader classLoader) |
static IConfig |
use(java.lang.Class<?> clazz)
Builds a config reader from .properties file which location is specified by annotations in the given class.
|
static IConfig |
use(java.io.File file)
Builds a config reader from .properties file specified by File object.
|
static IConfig |
use(java.nio.file.Path file)
Builds a config reader from .properties file specified by Path object.
|
static IConfig |
use(java.lang.String resourceName)
Builds a config reader from .properties file located in class path resources.
|
static IConfig |
use(org.xblackcat.sjpu.util.function.SupplierEx<java.io.InputStream,java.io.IOException> inputStreamSupplier)
Builds a config reader from .properties file located in class path resources.
|
static IConfig |
use(java.net.URL url)
Builds a config reader from .properties file specified by url.
|
static IConfig |
useEnv() |
static IConfig |
useJvm() |
public static final IConfig Defaults
public static IConfig use(java.io.File file)
file - .properties file.public static IConfig use(java.nio.file.Path file)
file - .properties file.public static IConfig use(java.net.URL url)
url - url to .properties file.public static IConfig use(java.lang.String resourceName)
resourceName - resource name.public static IConfig use(org.xblackcat.sjpu.util.function.SupplierEx<java.io.InputStream,java.io.IOException> inputStreamSupplier)
inputStreamSupplier - input stream provider with all thepublic static IConfig useEnv()
public static IConfig useJvm()
public static IConfig use(java.lang.Class<?> clazz) throws SettingsException
clazz - class annotated with @SettingsSource annotation.SettingsException - if interface methods are not annotated or interface is not annotated with
@SettingsSourcepublic static <T> T get(java.lang.Class<T> clazz)
throws SettingsException
If specified class marked with Optional annotation a null value will be
returned in case when required resource is not exists.
T - target interface for holding settings.clazz - target interface class for holding settings.SettingsException - if interface methods are not annotated or interface is not annotated with
@SettingsSourcepublic static IMutableConfig track(java.lang.Class<?> clazz) throws SettingsException, java.io.IOException, java.lang.UnsupportedOperationException
SettingsExceptionjava.io.IOExceptionjava.lang.UnsupportedOperationExceptionpublic static IMutableConfig track(java.lang.String resourceName) throws java.io.IOException, java.lang.UnsupportedOperationException
java.io.IOExceptionjava.lang.UnsupportedOperationExceptionpublic static IMutableConfig track(java.lang.String resourceName, java.lang.ClassLoader classLoader) throws java.io.IOException, java.lang.UnsupportedOperationException
java.io.IOExceptionjava.lang.UnsupportedOperationExceptionpublic static IMutableConfig track(java.nio.file.Path file) throws java.io.IOException, java.lang.UnsupportedOperationException
java.io.IOExceptionjava.lang.UnsupportedOperationExceptionpublic static IMutableConfig track(java.io.File file) throws java.io.IOException, java.lang.UnsupportedOperationException
java.io.IOExceptionjava.lang.UnsupportedOperationException