Class SearchOrder

java.lang.Object
io.github.arthurhoch.kissconfig.SearchOrder
All Implemented Interfaces:
Iterable<ConfigLocation>

public final class SearchOrder extends Object implements Iterable<ConfigLocation>
Immutable read order for configuration locations.

Search order is read order. With the default MergeStrategy.FILL_MISSING_ONLY, earlier sources have priority because they fill values first. With MergeStrategy.OVERRIDE_EXISTING, later sources win. With MergeStrategy.FAIL_ON_DUPLICATE, duplicate canonical keys fail. See docs/search-order.md for examples and preset details.

  • Method Details

    • of

      public static SearchOrder of(ConfigLocation... locations)
      Creates a search order from the supplied locations.
      Parameters:
      locations - locations in read order
      Returns:
      search order
    • defaults

      public static SearchOrder defaults()
      Returns the default read order.

      The default order reads classpath library defaults, application classpath resources, JAR directory files, working directory files, Java system properties, and OS environment variables. It does not include an env-file placeholder, but directory locations read env files when the builder has configured one.

      Returns:
      default search order
    • externalFirst

      public static SearchOrder externalFirst()
      Returns an external-first order designed for the default FILL_MISSING_ONLY merge strategy.

      Because search order is read order, external sources are read first and therefore have priority under MergeStrategy.FILL_MISSING_ONLY. With MergeStrategy.OVERRIDE_EXISTING, the last source wins and this interpretation changes.

      Returns:
      external-first search order
    • classpathOnly

      public static SearchOrder classpathOnly()
      Returns an order that reads only classpath library defaults and application classpath resources.
      Returns:
      classpath-only search order
    • production

      public static SearchOrder production()
      Returns a production-oriented external-first order.

      This order favors externally supplied values under the default MergeStrategy.FILL_MISSING_ONLY. It does not hardcode any /etc path, does not enable a profile, and does not enable env file loading by itself.

      Returns:
      production search order
    • test

      public static SearchOrder test()
      Returns a test-oriented order that reads the working directory before classpath resources.
      Returns:
      test search order
    • none

      public static SearchOrder none()
      Returns an empty order.
      Returns:
      empty search order
    • locations

      public List<ConfigLocation> locations()
      Returns locations in read order.
      Returns:
      immutable location list
    • iterator

      public Iterator<ConfigLocation> iterator()
      Specified by:
      iterator in interface Iterable<ConfigLocation>
    • toString

      public String toString()
      Overrides:
      toString in class Object