@Test public void testExtractArrayValueFromPreferenceValue() { assertThat(ArrayPreference.extractArrayElementsFromPreferenceValue(null), is(nullValue())); assertThat(ArrayPreference.extractArrayElementsFromPreferenceValue(""), is(nullValue())); assertThat(ArrayPreference.extractArrayElementsFromPreferenceValue("<int[]>[1, 2, 3]"), is("1, 2, 3")); }
@Nullable static String extractArrayElementsFromPreferenceValue(final String value) { if (TextUtils.isEmpty(value)) { return null; } final Matcher matcher = VALUE_PATTERN.matcher(value); return matcher.matches() ? matcher.group(2) : null; }
ArrayPreference extends SharedPreference<T> { @Nullable static String extractArrayElementsFromPreferenceValue(final String value) { if (TextUtils.isEmpty(value)) { return null; } final Matcher matcher = VALUE_PATTERN.matcher(value); return matcher.matches() ? matcher.group(2) : null; } }
ArrayPreference extends SharedPreference<T> { @Nullable static String extractArrayElementsFromPreferenceValue(final String value) { if (TextUtils.isEmpty(value)) { return null; } final Matcher matcher = VALUE_PATTERN.matcher(value); return matcher.matches() ? matcher.group(2) : null; } ArrayPreference(@NonNull final String key, @Nullable final T defValue); }
ArrayPreference extends SharedPreference<T> { @Nullable static String extractArrayElementsFromPreferenceValue(final String value) { if (TextUtils.isEmpty(value)) { return null; } final Matcher matcher = VALUE_PATTERN.matcher(value); return matcher.matches() ? matcher.group(2) : null; } ArrayPreference(@NonNull final String key, @Nullable final T defValue); @CheckResult static boolean putIntoPreferences(@NonNull final SharedPreferences preferences, @NonNull final String key, @Nullable final Object value); @SuppressWarnings("unchecked") @Nullable static A getFromPreferences(@NonNull final SharedPreferences preferences, @NonNull final String key, @Nullable final Object defValue); }
ArrayPreference extends SharedPreference<T> { @Nullable static String extractArrayElementsFromPreferenceValue(final String value) { if (TextUtils.isEmpty(value)) { return null; } final Matcher matcher = VALUE_PATTERN.matcher(value); return matcher.matches() ? matcher.group(2) : null; } ArrayPreference(@NonNull final String key, @Nullable final T defValue); @CheckResult static boolean putIntoPreferences(@NonNull final SharedPreferences preferences, @NonNull final String key, @Nullable final Object value); @SuppressWarnings("unchecked") @Nullable static A getFromPreferences(@NonNull final SharedPreferences preferences, @NonNull final String key, @Nullable final Object defValue);  }