SortModelPropertiesByRequiredFlag - simplified comparison to order boolean false first (#20602)

This commit is contained in:
Blake Lassiter
2025-02-09 05:55:41 -08:00
committed by GitHub
parent e1130c343a
commit 055605b075

View File

@@ -3190,14 +3190,7 @@ public class DefaultCodegen implements CodegenConfig {
}
protected void SortModelPropertiesByRequiredFlag(CodegenModel model) {
Comparator<CodegenProperty> comparator = new Comparator<CodegenProperty>() {
@Override
public int compare(CodegenProperty one, CodegenProperty another) {
if (one.required == another.required) return 0;
else if (one.required) return -1;
else return 1;
}
};
Comparator<CodegenProperty> comparator = Comparator.comparing(prop -> !prop.required);
Collections.sort(model.vars, comparator);
Collections.sort(model.allVars, comparator);
}