Package org.confng.api
Class ConfigSourceInfo
- java.lang.Object
-
- org.confng.api.ConfigSourceInfo
-
public class ConfigSourceInfo extends Object
Contains information about which configuration source provided a value.This class is used for debugging and diagnostics to understand where configuration values are coming from in the resolution chain.
Example usage:
ConfigSourceInfo info = ConfNG.getSourceInfo(MyConfig.DATABASE_URL); System.out.println("Value came from: " + info.getSourceName()); System.out.println("Priority: " + info.getPriority());- Since:
- 1.1.0
- Author:
- Bharat Kumar Malviya, GitHub: github.com/imBharatMalviya
- See Also:
ConfNG.getSourceInfo(ConfNGKey)
-
-
Constructor Summary
Constructors Constructor Description ConfigSourceInfo(String key, String sourceName, int priority, String value, boolean sensitive, boolean fromDefault)Creates a new ConfigSourceInfo.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ConfigSourceInfofromDefault(String key, String value, boolean sensitive)Creates a ConfigSourceInfo for a value from the key's default.StringgetKey()Gets the configuration key.intgetPriority()Gets the priority of the source.StringgetRawValue()Gets the raw value without masking.StringgetSourceName()Gets the name of the source that provided the value.StringgetValue()Gets the resolved value.booleanisFound()Checks if a value was found.booleanisFromDefault()Checks if the value came from the key's default.booleanisSensitive()Checks if the value is sensitive.static ConfigSourceInfonotFound(String key)Creates a ConfigSourceInfo for a missing value.StringtoString()
-
-
-
Constructor Detail
-
ConfigSourceInfo
public ConfigSourceInfo(String key, String sourceName, int priority, String value, boolean sensitive, boolean fromDefault)
Creates a new ConfigSourceInfo.- Parameters:
key- the configuration keysourceName- the name of the source that provided the valuepriority- the priority of the sourcevalue- the resolved valuesensitive- whether the value is sensitivefromDefault- whether the value came from the key's default
-
-
Method Detail
-
fromDefault
public static ConfigSourceInfo fromDefault(String key, String value, boolean sensitive)
Creates a ConfigSourceInfo for a value from the key's default.- Parameters:
key- the configuration keyvalue- the default valuesensitive- whether the value is sensitive- Returns:
- a ConfigSourceInfo indicating the value is from default
-
notFound
public static ConfigSourceInfo notFound(String key)
Creates a ConfigSourceInfo for a missing value.- Parameters:
key- the configuration key- Returns:
- a ConfigSourceInfo indicating no value was found
-
getKey
public String getKey()
Gets the configuration key.- Returns:
- the key name
-
getSourceName
public String getSourceName()
Gets the name of the source that provided the value.- Returns:
- the source name, or null if not found
-
getPriority
public int getPriority()
Gets the priority of the source.- Returns:
- the source priority
-
getValue
public String getValue()
Gets the resolved value. Returns "***MASKED***" for sensitive values.- Returns:
- the value or masked placeholder
-
getRawValue
public String getRawValue()
Gets the raw value without masking. Use with caution for sensitive values.- Returns:
- the raw value
-
isSensitive
public boolean isSensitive()
Checks if the value is sensitive.- Returns:
- true if sensitive
-
isFromDefault
public boolean isFromDefault()
Checks if the value came from the key's default.- Returns:
- true if from default
-
isFound
public boolean isFound()
Checks if a value was found.- Returns:
- true if a value was found
-
-