Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 38bc1add authored by Yu Shan's avatar Yu Shan
Browse files

Sort the enum types alphabetically.

Sort them so that they are in a stable order.

Test: Presubmit
Bug: 329269744
Change-Id: Ic541713024442ccfb88088f9bd829e71b20ef832
parent 84fc1ee6
Loading
Loading
Loading
Loading
+618 −618

File changed.

Preview size limit exceeded, changes collapsed.

+12 −1
Original line number Diff line number Diff line
@@ -47,7 +47,9 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.lang.reflect.Field;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@@ -321,7 +323,6 @@ public final class EmuMetadataGenerator {
            ValueField field = new ValueField(name, propertyId);

            List<JavadocBlockTag> blockTags = doc.getBlockTags();
            List<Integer> dataEnums = new ArrayList<>();
            for (int j = 0; j < blockTags.size(); j++) {
                String commentTagName = blockTags.get(j).getTagName();
                String commentTagContent = blockTags.get(j).getContent().toText();
@@ -344,6 +345,16 @@ public final class EmuMetadataGenerator {
            enumTypes.add(dataEnum);
        }

        // Sort the enum types based on their packageName, name.
        // Make sure VehicleProperty is always at the first.
        Collections.sort(enumTypes.subList(1, enumTypes.size()), (Enum enum1, Enum enum2) -> {
            var collator = Collator.getInstance();
            if (enum1.packageName.equals(enum2.packageName)) {
                return collator.compare(enum1.name, enum2.name);
            }
            return collator.compare(enum1.packageName, enum2.packageName);
        });

        // Output enumTypes as JSON to output.
        JSONArray jsonEnums = new JSONArray();
        for (int i = 0; i < enumTypes.size(); i++) {