Record Class NamedSemiring

java.lang.Object
java.lang.Record
com.darkcollective.relix.provenance.NamedSemiring
Record Components:
name - the canonical name, shown in listings and help; lower-cased on construction, and must not be blank
aliases - other names resolving to the same semiring; may be empty, and each is lower-cased on construction
semiring - the semiring itself
description - one line saying what the annotation means — what a user reads when choosing between installed semirings; must not be blank

public record NamedSemiring(String name, List<String> aliases, Semiring<?> semiring, String description) extends Record
A Semiring together with the names it answers to and a line describing it — one entry in the registry a --provenance request is resolved against.

Naming is kept out of Semiring deliberately. A semiring is an algebraic structure and its identity is its operations; what it is called is registry metadata, and the same structure can reasonably be offered twice under different names (min-plus is "tropical" to one caller and "shortest-path" to another). Putting the name here rather than on the algebra is what lets a library do that without declaring two classes that compute the same thing.

  • Constructor Details

    • NamedSemiring

      public NamedSemiring(String name, List<String> aliases, Semiring<?> semiring, String description)
      Canonicalises the entry: lower-cases every name, defensively copies the alias list, and rejects a blank name or description.
      Throws:
      NullPointerException - if any argument, or any alias, is null
      IllegalArgumentException - if the name, an alias, or the description is blank
  • Method Details

    • of

      public static NamedSemiring of(String name, Semiring<?> semiring, String description)
      An entry with no aliases.
      Parameters:
      name - the canonical name
      semiring - the semiring
      description - one line saying what the annotation means
      Returns:
      the entry
    • allNames

      public List<String> allNames()
      Returns every name this entry answers to — its canonical name followed by its aliases.
      Returns:
      every name this entry answers to — its canonical name followed by its aliases
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • aliases

      public List<String> aliases()
      Returns the value of the aliases record component.
      Returns:
      the value of the aliases record component
    • semiring

      public Semiring<?> semiring()
      Returns the value of the semiring record component.
      Returns:
      the value of the semiring record component
    • description

      public String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component