Class TypeSafeConfig

java.lang.Object
com.wualabs.qtsurfer.common.config.TypeSafeConfig

public class TypeSafeConfig extends Object
Base TypeSafe's Config wrapper class
  • Constructor Details

    • TypeSafeConfig

      public TypeSafeConfig(@NonNull @NonNull com.typesafe.config.Config config)
    • TypeSafeConfig

      public TypeSafeConfig(@NonNull @NonNull com.typesafe.config.Config config, String name)
    • TypeSafeConfig

      public TypeSafeConfig(@NonNull @NonNull com.typesafe.config.Config config, String name, boolean envOverrides)
  • Method Details

    • of

      public static TypeSafeConfig of(com.typesafe.config.Config config)
    • empty

      public static TypeSafeConfig empty()
    • from

      public static TypeSafeConfig from(@NonNull @NonNull String properties)
    • from

      public static TypeSafeConfig from(@NonNull @NonNull String properties, String name)
    • from

      public static TypeSafeConfig from(@NonNull @NonNull Properties properties)
    • from

      public static TypeSafeConfig from(@NonNull @NonNull Properties properties, String name)
      Creates a config from Java Properties, converting them to a map-backed TypeSafe Config with PROPERTIES syntax origin.
      Parameters:
      properties - the source properties
      name - optional config name
      Returns:
      a new TypeSafeConfig instance
    • from

      public static TypeSafeConfig from(@NonNull @NonNull Map<String, ? extends Object> map)
    • from

      public static TypeSafeConfig from(@NonNull @NonNull Map<String, ? extends Object> map, String name)
    • builder

      public static TypeSafeConfigBuilder builder()
    • isEmpty

      public boolean isEmpty()
    • withOverrides

      public TypeSafeConfig withOverrides(@NonNull @NonNull TypeSafeConfig overrides)
      Returns a new TypeSafeConfig where values from overrides take priority over values in this config, with missing keys falling back to this config.
      Parameters:
      overrides - config whose values take priority; if empty, returns this unchanged
      Returns:
      merged config with overrides applied
    • envOverrides

      public TypeSafeConfig envOverrides(boolean envOverrides)
    • hasPath

      public boolean hasPath(String path)
    • getString

      public String getString(@NonNull @NonNull String name, @NonNull @NonNull String defaultValue)
    • getString

      public Optional<String> getString(@NonNull @NonNull String name)
      Retrieves a string config value with environment variable override support. When envOverrides is enabled, checks for an environment variable matching the uppercase config key before falling back to the config file value.
      Parameters:
      name - the config key (also used as env var name in uppercase)
      Returns:
      the resolved value, or empty if not found in either source
    • getInt

      public int getInt(@NonNull @NonNull String name, int defaultValue)
    • getInteger

      public Optional<Integer> getInteger(@NonNull @NonNull String name)
    • getLong

      public long getLong(@NonNull @NonNull String name, long defaultValue)
    • getLong

      public Optional<Long> getLong(@NonNull @NonNull String name)
    • getDuration

      public Duration getDuration(@NonNull @NonNull String name, @NonNull @NonNull Duration defaultValue)
    • getDuration

      public Optional<Duration> getDuration(@NonNull @NonNull String name)
      Retrieves a duration config value with environment variable override support. When envOverrides is enabled, an environment variable matching the key (see getEnv(String)) takes priority and is parsed with the same HOCON duration syntax as file values (e.g. "30s", "5m"). Historically this getter ignored env vars entirely — the #222 config-drift class, where SOME_TIMEOUT=30s silently had no effect.
      Parameters:
      name - the config key (also used as env var name, see getEnv(String))
      Returns:
      the resolved duration, or empty if not found in either source
    • getBytes

      public Optional<Long> getBytes(@NonNull @NonNull String name)
      Retrieves a size-in-bytes config value with environment variable override support. When envOverrides is enabled, an environment variable matching the key (see getEnv(String)) takes priority and is parsed with the same HOCON size syntax as file values (e.g. "1024", "10MB"). Historically this getter ignored env vars entirely (T5.1).
      Parameters:
      name - the config key (also used as env var name, see getEnv(String))
      Returns:
      the resolved byte count, or empty if not found in either source
    • is

      public boolean is(@NonNull @NonNull String name)
    • is

      public boolean is(@NonNull @NonNull String name, boolean defaultValue)
    • getBoolean

      public Optional<Boolean> getBoolean(@NonNull @NonNull String name)
    • getConfig

      public Optional<com.typesafe.config.Config> getConfig(@NonNull @NonNull String name)
    • getTypeSafeConfig

      public Optional<TypeSafeConfig> getTypeSafeConfig(@NonNull @NonNull String name)
    • getStringList

      public List<String> getStringList(@NonNull @NonNull String name)
      Retrieves a string list with environment override and type fallback. Resolution order: (1) env var parsed as comma/semicolon-delimited list, (2) config list value, (3) if config value is a single string instead of a list, splits it into a list. Returns empty list if key is not found.
      Parameters:
      name - the config key
      Returns:
      the resolved list, or empty list if not found
    • getEnv

      public Optional<String> getEnv(@NonNull @NonNull String name)
    • toMap

      public Map<String, ? extends Object> toMap()
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getConfig

      public com.typesafe.config.Config getConfig()
    • getName

      public String getName()