UNPKG

@qudtlib/core

Version:

Data model for QUDTLib

50 lines (49 loc) 1.43 kB
import { getLastIriElement } from "./utils.js"; export class QuantityKind { constructor(iri, dimensionVector, symbol, labels) { this.iri = iri; this.applicableUnitIris = []; this.broaderQuantityKindIris = []; this.exactMatchIris = []; this.dimensionVectorIri = dimensionVector; this.symbol = symbol; if (typeof labels === "undefined") { this.labels = []; } else { this.labels = labels; } } getIriLocalname() { return getLastIriElement(this.iri); } addLabel(label) { this.labels.push(label); } hasLabel(label) { return this.labels.some((l) => label === l.text); } getLabelForLanguageTag(languageTag) { const label = this.labels.find((l) => languageTag === l.languageTag); return label?.text; } addApplicableUnitIri(unit) { this.applicableUnitIris.push(unit); } addBroaderQuantityKindIri(quantityKind) { this.broaderQuantityKindIris.push(quantityKind); } addExactMatchIri(exactMatch) { this.exactMatchIris.push(exactMatch); } equals(other) { return !!other && this.iri === other.iri; } toString() { if (this.symbol) { return this.symbol; } return "quantityKind:" + getLastIriElement(this.iri); } } //# sourceMappingURL=quantityKind.js.map