This commit is contained in:
2dust
2019-10-11 14:17:10 +08:00
commit 2d8ed22dba
222 changed files with 16718 additions and 0 deletions
@@ -0,0 +1,21 @@
package me.dozen.dpreference;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.Set;
public class StringSetConverter {
private static final Gson gson = new Gson();
public static String encode(Set<String> src) {
return gson.toJson(src);
}
public static Set<String> decode(String json) {
Type setType = new TypeToken<Set<String>>() {
}.getType();
return gson.fromJson(json, setType);
}
}