Class KissConfigBuilder
Defaults are application.properties, no env file, no profile,
SearchOrder.defaults(), and MergeStrategy.FILL_MISSING_ONLY. Env files are
opt-in through envFile(String), envFile(Path), or an explicit
ConfigLocation.envFile(String) in the configured search order. See
docs/search-order.md, docs/profiles.md, and docs/env-files.md for
detailed behavior.
-
Method Summary
Modifier and TypeMethodDescriptionConfigures env file loading.Configures env file loading.ignoreMissingExplicitFiles(boolean ignoreMissingExplicitFiles) Controls missing explicit file behavior.<T> KissConfigResult<T>Loads and maps configuration to the target record type, returning value, sources, map, and report.<T> TLoads and maps configuration to the target record type, returning only the mapped value.mergeStrategy(MergeStrategy mergeStrategy) Sets the merge strategy.Sets the active profile.propertyFile(String propertyFile) Sets the property file name or path used by compatible locations.propertyFile(Path propertyFile) Sets the property file name or path used by compatible locations.searchOrder(SearchOrder searchOrder) Sets the source search order.
-
Method Details
-
propertyFile
Sets the property file name or path used by compatible locations.With an active profile, directory and classpath locations also attempt a profile variant such as
application-prod.propertiesfor profileprod.- Parameters:
propertyFile- property file- Returns:
- this builder
-
propertyFile
Sets the property file name or path used by compatible locations.With an active profile, directory and classpath locations also attempt a profile variant such as
application-prod.propertiesfor profileprod.- Parameters:
propertyFile- property file- Returns:
- this builder
-
envFile
Configures env file loading.Env files are not loaded by default. When this method is used, directory-based locations attempt the configured env file and, when a profile is active, a profile variant. For
.envand profileprod, the profile variant is.env.prod.- Parameters:
envFile- env file- Returns:
- this builder
-
envFile
Configures env file loading.Env files are not loaded by default. When this method is used, directory-based locations attempt the configured env file and, when a profile is active, a profile variant. For
myapp.envand profileprod, the profile variant ismyapp-prod.env.- Parameters:
envFile- env file- Returns:
- this builder
-
profile
Sets the active profile.Profiles are validated against
[a-zA-Z0-9_-]+. Profiles are not enabled automatically bySearchOrder.production().- Parameters:
profile- profile name matching [a-zA-Z0-9_-]+- Returns:
- this builder
-
searchOrder
Sets the source search order.SearchOrderis read order. Priority depends on the activeMergeStrategy.- Parameters:
searchOrder- search order- Returns:
- this builder
-
mergeStrategy
Sets the merge strategy.The default is
MergeStrategy.FILL_MISSING_ONLY. Override and duplicate-fail behavior must be selected explicitly.- Parameters:
mergeStrategy- merge strategy- Returns:
- this builder
-
ignoreMissingExplicitFiles
Controls missing explicit file behavior.Auto-discovered missing files are skipped. Explicit files declared through
ConfigLocation.file(String)orConfigLocation.envFile(String)fail when missing unless this is set totrue.- Parameters:
ignoreMissingExplicitFiles- true to skip missing explicit files- Returns:
- this builder
-
mapTo
Loads and maps configuration to the target record type, returning only the mapped value.- Type Parameters:
T- target type- Parameters:
targetType- target type- Returns:
- mapped configuration object
-
load
Loads and maps configuration to the target record type, returning value, sources, map, and report.- Type Parameters:
T- target type- Parameters:
targetType- target type- Returns:
- load result
-