Skip to content

Commit 3403451

Browse files
authored
Update sorting of unts matching a factor units query (#120)
1 parent b5f0f87 commit 3403451

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

  • qudtlib-js-gen/src/main/resources/template
  • qudtlib-main/src/main/java/io/github/qudtlib

qudtlib-js-gen/src/main/resources/template/units.ts.ftl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ export * from "@qudtlib/core";
6868
${optStr(unit.currencyCode)},
6969
${optNum(unit.currencyNumber)},
7070
[${unit.unitOfSystems?map(s -> "\""+s.iri+"\"")?join(",")}],
71+
${unit.dependents},
72+
<#if unit.isDeprecated()>
73+
true,
74+
<#else>
75+
false,
76+
</#if>
77+
<#if unit.isGenerated()>
78+
true
79+
<#else>
80+
false
81+
</#if>
7182
);
7283
<#list unit.labels as label>
7384
unit.addLabel(new LangString(${q(label.string)}, ${optStr(label.languageTag)}));

qudtlib-main/src/main/java/io/github/qudtlib/Qudt.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ public int compare(Unit left, Unit right) {
688688
}
689689
if (right.isDefinedAsOtherUnit()
690690
&& left.getFactorUnits().getFactorUnits().size() == 1
691-
&& left.getFactorUnits().getFactorUnits().get(0).getUnit().equals(left)
691+
&& left.getFactorUnits().getFactorUnits().get(0).getUnit().equals(right)
692692
&& right.getFactorUnits().getFactorUnits().get(0).getExponent()
693693
== left.getFactorUnits().getFactorUnits().get(0).getExponent()) {
694694
return -1; // if a unit is just another name of another unit with same exponent,

0 commit comments

Comments
 (0)