Class RawProviderConfiguration

java.lang.Object
com.agentforge4j.llm.RawProviderConfiguration

public final class RawProviderConfiguration extends Object
Immutable neutral view over a provider's agentforge4j.llm.<providerId>.* configuration subtree, handed to a LlmClientConfigurationAdapter. Keys are the canonical property names in kebab-case (for example api-key, deployment-name); values are their raw string forms.

Per-key values are resolved through a RawConfigurationSource, so the host configuration decides how a key is looked up (including how alternate key spellings resolve to a canonical key) while this class — and the provider adapters that consume it — stay independent of any particular configuration mechanism. A parse failure throws LlmProviderConfigurationException naming the full property key (agentforge4j.llm.<providerId>.<key>) — never the value, in case it is a secret.

get(String) returns a key's value whenever the key is present, even if blank — presence semantics; require(String) and the typed accessors treat a blank value as absent.

The enumeration views (isEmpty(), keys(), asMap()) reflect the keys discovered from configuration sources that can be enumerated by canonical key. They are best-effort for sources whose canonical keys cannot be reconstructed; per-key accessors remain authoritative for every source. Adapters therefore gate activation on explicit keys (an api-key, an enabled flag) rather than on isEmpty().

  • Constructor Details

    • RawProviderConfiguration

      public RawProviderConfiguration(String providerId, RawConfigurationSource source, Set<String> presentKeys)
      Parameters:
      providerId - the provider id whose subtree this represents; must not be blank
      source - the per-key value lookup for this provider's subtree; must not be null
      presentKeys - the keys discovered from enumerable property sources, used for the enumeration views; must not be null (copied immutably)
  • Method Details

    • providerId

      public String providerId()
      Returns:
      the provider id this subtree belongs to
    • isEmpty

      public boolean isEmpty()
      Returns:
      true when no properties are discovered under this provider's subtree (best-effort; see the class documentation)
    • keys

      public Set<String> keys()
      Returns:
      the discovered property keys (immutable; best-effort, see the class documentation)
    • get

      public Optional<String> get(String key)
      Returns a key's value whenever the key is present, including a blank value (presence semantics).
      Parameters:
      key - the property key (kebab-case, relative to the provider subtree)
      Returns:
      the value if the key is present, otherwise empty
    • require

      public String require(String key)
      Returns the required, non-blank value for key.
      Parameters:
      key - the property key
      Returns:
      the non-blank value
      Throws:
      LlmProviderConfigurationException - if the key is absent or blank
    • getInt

      public Optional<Integer> getInt(String key)
      Parameters:
      key - the property key
      Returns:
      the integer value when present and non-blank
      Throws:
      LlmProviderConfigurationException - if present but not a valid integer
    • getDouble

      public Optional<Double> getDouble(String key)
      Parameters:
      key - the property key
      Returns:
      the decimal value when present and non-blank
      Throws:
      LlmProviderConfigurationException - if present but not a valid decimal number
    • getDuration

      public Optional<Duration> getDuration(String key)
      Parses a duration in either ISO-8601 form (for example PT15S) or the compact shorthand (an amount plus an optional ns/us/ms/s/m/h/d unit suffix, defaulting to milliseconds — for example 15s, 2m, 500ms, 5000).
      Parameters:
      key - the property key
      Returns:
      the duration value when present and non-blank
      Throws:
      LlmProviderConfigurationException - if present but not a valid ISO-8601 or shorthand duration
    • getBoolean

      public Optional<Boolean> getBoolean(String key)
      Parameters:
      key - the property key
      Returns:
      the boolean value when present and non-blank (strictly true/false, case-insensitive)
      Throws:
      LlmProviderConfigurationException - if present but not a strict boolean
    • isTrue

      public boolean isTrue(String key)
      Returns whether key is set to the literal "true" (case-insensitive), tolerating any other value — absent, blank, "false", or malformed ("yes", "1", ...) — as false rather than throwing. Intended for enabled-style activation gates, where a malformed value must not fail startup; for every other use prefer getBoolean(String), which fails loudly on a malformed value.
      Parameters:
      key - the property key
      Returns:
      true only when the value is the literal "true" (case-insensitive)
    • asMap

      public Map<String,String> asMap()
      Returns:
      an immutable map of the discovered keys to their resolved values (best-effort; see the class documentation)