package com.faforever.client.remote.gson; import com.faforever.client.remote.domain.GameAccess; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import java.io.IOException; public class GameAccessTypeAdapter extends TypeAdapter<GameAccess> { public static final GameAccessTypeAdapter INSTANCE = new GameAccessTypeAdapter(); private GameAccessTypeAdapter() { } @Override public void write(JsonWriter out, GameAccess value) throws IOException { if (value == null) { out.nullValue(); } else { out.value(value.getString()); } } @Override public GameAccess read(JsonReader in) throws IOException { return GameAccess.fromString(in.nextString()); } }