Inceptum/launcher/src/main/java/io/gitlab/jfronny/inceptum/launcher/gson/ModMetaSourcesAdapter.java

29 lines
1.0 KiB
Java

package io.gitlab.jfronny.inceptum.launcher.gson;
import gsoncompile.extensions.io.gitlab.jfronny.inceptum.launcher.system.source.ModSource.GC_ModSource;
import io.gitlab.jfronny.gson.stream.JsonReader;
import io.gitlab.jfronny.gson.stream.JsonWriter;
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.ModMeta$Sources;
import io.gitlab.jfronny.inceptum.launcher.system.source.ModSource;
import java.io.IOException;
import java.util.Optional;
public class ModMetaSourcesAdapter {
public static void write(JsonWriter writer, ModMeta$Sources value) throws IOException {
writer.beginArray();
for (ModSource source : value.keySet()) GC_ModSource.write(source, writer);
writer.endArray();
}
public static ModMeta$Sources read(JsonReader reader) throws IOException {
reader.beginArray();
ModMeta$Sources sources = new ModMeta$Sources();
while (reader.hasNext()) {
sources.put(GC_ModSource.read(reader), Optional.empty());
}
reader.endArray();
return sources;
}
}