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 blankaliases- other names resolving to the same semiring; may be empty, and each is lower-cased on constructionsemiring- the semiring itselfdescription- 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaliases()Returns the value of thealiasesrecord component.allNames()Returns every name this entry answers to — its canonical name followed by its aliases.Returns the value of thedescriptionrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.static NamedSemiringAn entry with no aliases.Semiring<?> semiring()Returns the value of thesemiringrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
NamedSemiring
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 nullIllegalArgumentException- if the name, an alias, or the description is blank
-
-
Method Details
-
of
An entry with no aliases.- Parameters:
name- the canonical namesemiring- the semiringdescription- one line saying what the annotation means- Returns:
- the entry
-
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
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
aliases
Returns the value of thealiasesrecord component.- Returns:
- the value of the
aliasesrecord component
-
semiring
Returns the value of thesemiringrecord component.- Returns:
- the value of the
semiringrecord component
-
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-