Class 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 Detail

      • ConfigSourceInfo

        public ConfigSourceInfo​(String key,
                                String sourceName,
                                int priority,
                                String value,
                                boolean sensitive,
                                boolean fromDefault)
        Creates a new ConfigSourceInfo.
        Parameters:
        key - the configuration key
        sourceName - the name of the source that provided the value
        priority - the priority of the source
        value - the resolved value
        sensitive - whether the value is sensitive
        fromDefault - 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 key
        value - the default value
        sensitive - 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