UNPKG

@qudtlib/core

Version:

Data model for QUDTLib

1 lines 2.91 kB
{"version":3,"sources":["quantityKind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,qBAAa,YAAa,YAAW,cAAc,CAAC,YAAY,CAAC;IAC/D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,uBAAuB,EAAE,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;gBAGhC,GAAG,EAAE,MAAM,EACX,eAAe,CAAC,EAAE,MAAM,EACxB,MAAM,CAAC,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,UAAU,EAAE;IAevB,eAAe,IAAI,MAAM;IAIzB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAIjC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIhC,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAK/D,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIxC,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAGrD,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAI1C,MAAM,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,OAAO;IAIrC,QAAQ,IAAI,MAAM;CAMnB","file":"quantityKind.d.ts","sourcesContent":["import { SupportsEquals } from \"./baseTypes.js\";\nimport { LangString } from \"./langString.js\";\nimport { getLastIriElement } from \"./utils.js\";\n\nexport class QuantityKind implements SupportsEquals<QuantityKind> {\n readonly iri: string;\n readonly labels: LangString[];\n readonly applicableUnitIris: string[];\n readonly broaderQuantityKindIris: string[];\n readonly dimensionVectorIri?: string;\n readonly symbol?: string;\n readonly exactMatchIris: string[];\n\n constructor(\n iri: string,\n dimensionVector?: string,\n symbol?: string,\n labels?: LangString[]\n ) {\n this.iri = iri;\n this.applicableUnitIris = [];\n this.broaderQuantityKindIris = [];\n this.exactMatchIris = [];\n this.dimensionVectorIri = dimensionVector;\n this.symbol = symbol;\n if (typeof labels === \"undefined\") {\n this.labels = [];\n } else {\n this.labels = labels;\n }\n }\n\n getIriLocalname(): string {\n return getLastIriElement(this.iri);\n }\n\n addLabel(label: LangString): void {\n this.labels.push(label);\n }\n\n hasLabel(label: string): boolean {\n return this.labels.some((l) => label === l.text);\n }\n\n getLabelForLanguageTag(languageTag: string): string | undefined {\n const label = this.labels.find((l) => languageTag === l.languageTag);\n return label?.text;\n }\n\n addApplicableUnitIri(unit: string): void {\n this.applicableUnitIris.push(unit);\n }\n\n addBroaderQuantityKindIri(quantityKind: string): void {\n this.broaderQuantityKindIris.push(quantityKind);\n }\n addExactMatchIri(exactMatch: string): void {\n this.exactMatchIris.push(exactMatch);\n }\n\n equals(other?: QuantityKind): boolean {\n return !!other && this.iri === other.iri;\n }\n\n toString(): string {\n if (this.symbol) {\n return this.symbol;\n }\n return \"quantityKind:\" + getLastIriElement(this.iri);\n }\n}\n"]}