GsonPreference extends Preference<T> { @Override public T get() { if (exists()) { return getGson().fromJson(mStringPreference.get(), mType); } else { return getDefaultValue(); } } GsonPreference(final String name, final String key, final Type type,
            @Nullable final T defaultValue); @Override boolean exists(); @Override T get(); @NonNull final Gson getGson();  }
@Test public void testGet() throws Exception { assertNull(mNullPref.get()); Employee sheik = mSheikPref.get(); assertNotNull(sheik); assertEquals(sheik.mId, SHEIK_ID); assertEquals(sheik.mName, SHEIK_NAME); }
@Test public void testSet() throws Exception { Employee sheik = new Employee(); sheik.mId = 20; sheik.mName = "Link"; mSheikPref.set(sheik); sheik = mSheikPref.get(); assertNotNull(sheik); assertEquals(sheik.mId, 20); assertEquals(sheik.mName, "Link"); }