This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PetConverter extends PreferenceTypeConverter<Pet> { | |
private final Gson gson; | |
/** | |
* default constructor will be called by PreferenceRoom | |
*/ | |
public PetConverter() { | |
this.gson = new Gson(); | |
} | |
@Override | |
public String convertObject(Pet pet) { | |
return gson.toJson(pet); | |
} | |
@Override | |
public Pet convertType(String string) { | |
return gson.fromJson(string, Pet.class); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment