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;
*
* @author Daniel Kirschten
*/
- public static void serialize(ViewModel model, IdentifierGetter idGetter, String targetPath) throws IOException
+ public static void serialize(ViewModel model, IdentifyParams idParams, String targetPath) throws IOException
{
- JsonHandler.writeJson(serialize(model, idGetter), targetPath);
+ JsonHandler.writeJson(serialize(model, idParams), targetPath);
}
/**
*/
public static ViewModelParams serialize(ViewModel model)
{
- return serialize(model, new IdentifierGetter());
+ return serialize(model, new IdentifyParams());
}
// "core" methods
* @author Fabian Stemmler
* @author Daniel Kirschten
*/
- public static ViewModelParams serialize(ViewModel model, IdentifierGetter idGetter)
+ public static ViewModelParams serialize(ViewModel model, IdentifyParams idParams)
{
ViewModelParams modelParams = new ViewModelParams(CURRENT_JSON_VERSION);
compParams.params = innerCompCasted.paramsForSerializingOverride;
} else
{
- compParams.id = idGetter.componentIDs.apply(component);
- compParams.params = component.getParamsForSerializing(idGetter);
+ compParams.id = component.getIDForSerializing(idParams);
+ compParams.params = component.getParamsForSerializingJSON(idParams);
}
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<>();
innerWireParams.path = innerWire.getPath();
}
modelParams.wires = wiresParams.toArray(WireParams[]::new);
+ Arrays.sort(modelParams.wires, Comparator.comparing(c -> c.name));
return modelParams;
}