Skip to content

Commit 404abf3

Browse files
Merge pull request #154 from vojtechhabarta/revert-150-glen/sort-discriminant-types
Revert "Add option to sort discriminant types"
2 parents dcc804d + a474387 commit 404abf3

File tree

6 files changed

+3
-104
lines changed

6 files changed

+3
-104
lines changed

typescript-generator-core/src/main/java/cz/habarta/typescript/generator/Settings.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public class Settings {
5656
public boolean restOptionsTypeIsGeneric;
5757
public TypeProcessor customTypeProcessor = null;
5858
public boolean sortDeclarations = false;
59-
public boolean sortDiscriminantTypes = false;
6059
public boolean sortTypeDeclarations = false;
6160
public boolean noFileComment = false;
6261
public List<File> javadocXmlFiles = null;

typescript-generator-core/src/main/java/cz/habarta/typescript/generator/TsType.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,26 +166,16 @@ public String format(Settings settings) {
166166
public static class UnionType extends TsType {
167167

168168
public final List<TsType> types;
169-
public final boolean sort;
170169

171170
public UnionType(List<? extends TsType> types) {
172-
this(types, false);
173-
}
174-
175-
public UnionType(List<? extends TsType> types, boolean sort) {
176171
this.types = new ArrayList<TsType>(new LinkedHashSet<TsType>(types));
177-
this.sort = sort;
178172
}
179173

180174
@Override
181175
public String format(Settings settings) {
182-
List<String> formattedTypes = format(this.types, settings);
183-
if (this.sort) {
184-
Collections.sort(formattedTypes);
185-
}
186-
return formattedTypes.isEmpty()
176+
return types.isEmpty()
187177
? "never"
188-
: Utils.join(formattedTypes, " | ");
178+
: Utils.join(format(types, settings), " | ");
189179
}
190180

191181
}

typescript-generator-core/src/main/java/cz/habarta/typescript/generator/compiler/ModelCompiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private <T> TsBeanModel processBean(SymbolTable symbolTable, Model model, Map<Ty
150150
}
151151
final TsType discriminantType = literals.isEmpty()
152152
? TsType.String
153-
: new TsType.UnionType(literals, settings.sortDiscriminantTypes);
153+
: new TsType.UnionType(literals);
154154
properties.add(0, new TsPropertyModel(bean.getDiscriminantProperty(), discriminantType, settings.declarePropertiesAsReadOnly, null));
155155
}
156156

typescript-generator-core/src/test/java/cz/habarta/typescript/generator/SortedDiscriminantTypesTest.java

Lines changed: 0 additions & 81 deletions
This file was deleted.

typescript-generator-gradle-plugin/src/main/java/cz/habarta/typescript/generator/gradle/GenerateTask.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public class GenerateTask extends DefaultTask {
5151
public String restOptionsType;
5252
public String customTypeProcessor;
5353
public boolean sortDeclarations;
54-
public boolean sortDiscriminantTypes;
5554
public boolean sortTypeDeclarations;
5655
public boolean noFileComment;
5756
public List<File> javadocXmlFiles;
@@ -124,7 +123,6 @@ public void generate() throws Exception {
124123
settings.setRestOptionsType(restOptionsType);
125124
settings.loadCustomTypeProcessor(classLoader, customTypeProcessor);
126125
settings.sortDeclarations = sortDeclarations;
127-
settings.sortDiscriminantTypes = sortDiscriminantTypes;
128126
settings.sortTypeDeclarations = sortTypeDeclarations;
129127
settings.noFileComment = noFileComment;
130128
settings.javadocXmlFiles = javadocXmlFiles;

typescript-generator-maven-plugin/src/main/java/cz/habarta/typescript/generator/maven/GenerateMojo.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,6 @@ public class GenerateMojo extends AbstractMojo {
317317
@Parameter
318318
private boolean sortDeclarations;
319319

320-
/**
321-
* If true discriminant types will be sorted alphabetically.
322-
*/
323-
@Parameter
324-
private boolean sortDiscriminantTypes;
325-
326320
/**
327321
* If true TypeScript type declarations (interfaces) will be sorted alphabetically.
328322
*/
@@ -468,7 +462,6 @@ public void execute() {
468462
settings.setRestOptionsType(restOptionsType);
469463
settings.loadCustomTypeProcessor(classLoader, customTypeProcessor);
470464
settings.sortDeclarations = sortDeclarations;
471-
settings.sortDiscriminantTypes = sortDiscriminantTypes;
472465
settings.sortTypeDeclarations = sortTypeDeclarations;
473466
settings.noFileComment = noFileComment;
474467
settings.javadocXmlFiles = javadocXmlFiles;

0 commit comments

Comments
 (0)