java.lang.Object
com.darkcollective.relix.provenance.SemiringCatalog

public final class SemiringCatalog extends Object
Which semirings are installed — the bundled six plus every one a discovered SemiringLibrary offers, resolved by name.

Discovery happens once. Two independently-populated catalogs can disagree about what a name means, and a name is what a --provenance request carries, so installed() memoises a single scan and everything else reads it.

Clashes

Libraries are consulted in descending priority, and the first to claim a name keeps it. A loss is reported through System.Logger rather than being resolved silently — a semiring that turned out not to be the one installed is otherwise indistinguishable from one that is.
  • Method Details

    • installed

      public static SemiringCatalog installed()
      Returns the catalog of installed semirings. Discovery runs once, on first call.
      Returns:
      the catalog of installed semirings
    • discover

      public static SemiringCatalog discover()
      Runs ServiceLoader discovery afresh, over the bundled library plus every installed one. Prefer installed(); this exists for a host that changes its class loader between runs.

      A provider that fails to load is logged and skipped rather than failing the scan, so one broken library on the path does not take the built-in semirings with it.

      Returns:
      a freshly discovered catalog
    • of

      public static SemiringCatalog of(List<SemiringLibrary> libraries)
      A catalog of exactly the given libraries — the bundled six are not added. For a test or an embedder assembling its own set.
      Parameters:
      libraries - the libraries to read; must not be null
      Returns:
      the catalog
    • withBuiltins

      public static SemiringCatalog withBuiltins(List<SemiringLibrary> extra)
      A catalog holding the bundled semirings and the given libraries, which are consulted ahead of the bundled ones at equal priority.
      Parameters:
      extra - the additional libraries; must not be null
      Returns:
      the catalog
    • empty

      public static SemiringCatalog empty()
      Returns an empty catalog, holding no semirings at all.
      Returns:
      an empty catalog, holding no semirings at all
    • byName

      public Optional<Semiring<?>> byName(String name)
      Resolves a semiring by (case-insensitive) name or alias.
      Parameters:
      name - the name; may be null
      Returns:
      the matching semiring, or empty if name is null or unknown
    • entry

      public Optional<NamedSemiring> entry(String name)
      Resolves a registry entry by (case-insensitive) name or alias — the semiring together with what it is called and what it means.
      Parameters:
      name - the name; may be null
      Returns:
      the matching entry, or empty if name is null or unknown
    • entries

      public List<NamedSemiring> entries()
      Returns every installed semiring, in claiming order. Each appears once, under its canonical name; aliases resolve through byName but are not listed.
      Returns:
      every installed semiring, in claiming order
    • names

      public List<String> names()
      Returns the canonical names of every installed semiring, in claiming order. This is the list to show in help and error messages.
      Returns:
      the canonical names of every installed semiring, in claiming order