interfacePins, components, wires in JSON files are now sorted by name
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Sat, 31 Aug 2019 16:52:52 +0000 (18:52 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Sat, 31 Aug 2019 16:52:52 +0000 (18:52 +0200)
net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/SubmodelComponentSerializer.java
net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/ViewModelSerializer.java

index 234361d..843c356 100644 (file)
@@ -1,6 +1,8 @@
 package net.mograsim.logic.model.serializing;
 
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.Comparator;
 
 import com.google.gson.JsonElement;
 
@@ -216,6 +218,7 @@ public final class SubmodelComponentSerializer
                        i++;
                }
                params.interfacePins = iPins;
+               Arrays.sort(params.interfacePins, Comparator.comparing(p -> p.name));
 
                Renderer symbolRenderer = comp.getSymbolRenderer();
                if (symbolRenderer != null)
index ffd18c9..38bdf9c 100644 (file)
@@ -1,7 +1,9 @@
 package net.mograsim.logic.model.serializing;
 
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -161,6 +163,7 @@ public class ViewModelSerializer
                        compParams.name = component.name;
                }
                modelParams.components = componentsParams.toArray(ComponentParams[]::new);
+               Arrays.sort(modelParams.components, Comparator.comparing(c -> c.name));
 
                Collection<GUIWire> wires = model.getWiresByName().values();
                Set<WireParams> wiresParams = new HashSet<>();
@@ -180,6 +183,7 @@ public class ViewModelSerializer
                        innerWireParams.path = innerWire.getPath();
                }
                modelParams.wires = wiresParams.toArray(WireParams[]::new);
+               Arrays.sort(modelParams.wires, Comparator.comparing(c -> c.name));
 
                return modelParams;
        }