java.lang.Object
com.darkcollective.relix.solver.SolverCatalog

public final class SolverCatalog extends Object
The installed MathProgrammingSolvers, discovered with ServiceLoader.

Discovery lives here, in the module that declares the SPI, for the reason it does for every other provider seam: ServiceLoader.load binds against the calling module, so a consumer needs no uses clause of its own — and asking twice can produce two answers. installed() therefore discovers once per JVM and hands the same catalog to the planner (which checks a solver exists before the query runs) and to the executor (which uses it).

An empty catalog is a supported state, not an error: a build that installs no solver still parses, analyses, optimises and executes everything except the two operators that need one, and those report it before any rows are read. Discovery reaches that state by any route, an installed provider that cannot be instantiated included — see discover().

  • Method Details

    • installed

      public static SolverCatalog installed()
      The catalog of solvers installed in this runtime, discovered on first use.
      Returns:
      the installed catalog, possibly empty
    • discover

      public static SolverCatalog discover()
      Runs ServiceLoader discovery afresh. Prefer installed(); this exists for a host that changes its class loader between runs.

      A provider that cannot be instantiated is skipped with a warning rather than failing the scan. That is what makes the empty catalog this class documents as supported actually reachable: the shipped provider is bundled with its solver library, so an installed-but-unloadable solver is what a host that removes that library has, and aborting discovery there would take down every query rather than the two operators that need a solver.

      Returns:
      a catalog over the currently discoverable solvers, possibly empty
    • of

      public static SolverCatalog of(List<MathProgrammingSolver> solvers)
      A catalog over an explicit list — the seam a test or an embedder uses to install its own solver without touching the module path.
      Parameters:
      solvers - the solvers to offer, highest priority winning
      Returns:
      a catalog over them
    • empty

      public static SolverCatalog empty()
      A catalog with no solver in it — what a runtime that installs no provider has.
      Returns:
      the empty catalog
    • solver

      public Optional<MathProgrammingSolver> solver()
      The solver to use: the highest-priority installed one.
      Returns:
      the chosen solver, or empty if none is installed
    • isEmpty

      public boolean isEmpty()
      Returns:
      whether no solver is installed
    • solvers

      public List<MathProgrammingSolver> solvers()
      Every installed solver, highest priority first.
      Returns:
      the installed solvers