Prefser { public <T> T get(@NonNull String key, @NonNull Class<T> classOfT, T defaultValue) { Preconditions.checkNotNull(key, KEY_IS_NULL); Preconditions.checkNotNull(classOfT, CLASS_OF_T_IS_NULL); if (!contains(key) && defaultValue == null) { return null; } return get(key, TypeToken.fromClass(classOfT), defaultValue); } Prefser(@NonNull Context context);  Prefser(@NonNull Context context, @NonNull JsonConverter jsonConverter);  Prefser(@NonNull SharedPreferences sharedPreferences); @SuppressLint("CommitPrefEdits")  Prefser(@NonNull SharedPreferences sharedPreferences,
      @NonNull JsonConverter jsonConverter); SharedPreferences getPreferences(); boolean contains(String key); Observable<T> getAndObserve(String key, Class<T> classOfT, T defaultValue); Observable<T> getAndObserve(final String key, final TypeToken<T> typeTokenOfT,
      final T defaultValue); Observable<T> observe(@NonNull String key, @NonNull Class<T> classOfT,
      T defaultValue); Observable<T> observe(@NonNull final String key,
      @NonNull final TypeToken<T> typeTokenOfT, final T defaultValue); T get(@NonNull String key, @NonNull Class<T> classOfT, T defaultValue); T get(@NonNull String key, @NonNull TypeToken<T> typeTokenOfT, T defaultValue); Observable<String> observePreferences(); void put(@NonNull String key, @NonNull T value); void put(@NonNull String key, @NonNull T value, @NonNull TypeToken<T> typeTokenOfT); void remove(@NonNull String key); void clear(); int size();  }
@Test(expected = NullPointerException.class) public void testShouldThrowAnExceptionWhenKeyForGetIsNull() { String key = null; Class<String> classOfT = String.class; prefser.get(key, classOfT, ""); }
@Test(expected = NullPointerException.class) public void testShouldThrowAnExceptionWhenKeyForGetWithDefaultValueIsNull() { String key = null; Class<String> classOfT = String.class; String defaultValue = "some default value"; prefser.get(key, classOfT, defaultValue); }
@Test(expected = NullPointerException.class) public void testShouldThrowAnExceptionWhenClassOfTForGetWithDefaultValueIsNull() { String key = GIVEN_KEY; Class<String> classOfT = null; String defaultValue = "some default value"; prefser.get(key, classOfT, defaultValue); }