@Test public void testResolveArrayClassByName() { assertEquals(null, ArrayPreference.resolveArrayClassByName("Date[]")); assertEquals(boolean[].class, ArrayPreference.resolveArrayClassByName("boolean[]")); assertEquals(byte[].class, ArrayPreference.resolveArrayClassByName("byte[]")); assertEquals(char[].class, ArrayPreference.resolveArrayClassByName("char[]")); assertEquals(short[].class, ArrayPreference.resolveArrayClassByName("short[]")); assertEquals(int[].class, ArrayPreference.resolveArrayClassByName("int[]")); assertEquals(float[].class, ArrayPreference.resolveArrayClassByName("float[]")); assertEquals(long[].class, ArrayPreference.resolveArrayClassByName("long[]")); assertEquals(double[].class, ArrayPreference.resolveArrayClassByName("double[]")); assertEquals(Boolean[].class, ArrayPreference.resolveArrayClassByName("Boolean[]")); assertEquals(Byte[].class, ArrayPreference.resolveArrayClassByName("Byte[]")); assertEquals(Character[].class, ArrayPreference.resolveArrayClassByName("Character[]")); assertEquals(Short[].class, ArrayPreference.resolveArrayClassByName("Short[]")); assertEquals(Integer[].class, ArrayPreference.resolveArrayClassByName("Integer[]")); assertEquals(Float[].class, ArrayPreference.resolveArrayClassByName("Float[]")); assertEquals(Long[].class, ArrayPreference.resolveArrayClassByName("Long[]")); assertEquals(Double[].class, ArrayPreference.resolveArrayClassByName("Double[]")); assertEquals(String[].class, ArrayPreference.resolveArrayClassByName("String[]")); }
static Class<?> resolveArrayClassByName(final String arrayClassName) { switch (arrayClassName) { case "byte[]": return byte[].class; case "char[]": return char[].class; case "short[]": return short[].class; case "int[]": return int[].class; case "float[]": return float[].class; case "long[]": return long[].class; case "double[]": return double[].class; case "boolean[]": return boolean[].class; case "Byte[]": return Byte[].class; case "Character[]": return Character[].class; case "Short[]": return Short[].class; case "Integer[]": return Integer[].class; case "Float[]": return Float[].class; case "Long[]": return Long[].class; case "Double[]": return Double[].class; case "Boolean[]": return Boolean[].class; case "String[]": return String[].class; default: return null; } }
ArrayPreference extends SharedPreference<T> { static Class<?> resolveArrayClassByName(final String arrayClassName) { switch (arrayClassName) { case "byte[]": return byte[].class; case "char[]": return char[].class; case "short[]": return short[].class; case "int[]": return int[].class; case "float[]": return float[].class; case "long[]": return long[].class; case "double[]": return double[].class; case "boolean[]": return boolean[].class; case "Byte[]": return Byte[].class; case "Character[]": return Character[].class; case "Short[]": return Short[].class; case "Integer[]": return Integer[].class; case "Float[]": return Float[].class; case "Long[]": return Long[].class; case "Double[]": return Double[].class; case "Boolean[]": return Boolean[].class; case "String[]": return String[].class; default: return null; } } }
ArrayPreference extends SharedPreference<T> { static Class<?> resolveArrayClassByName(final String arrayClassName) { switch (arrayClassName) { case "byte[]": return byte[].class; case "char[]": return char[].class; case "short[]": return short[].class; case "int[]": return int[].class; case "float[]": return float[].class; case "long[]": return long[].class; case "double[]": return double[].class; case "boolean[]": return boolean[].class; case "Byte[]": return Byte[].class; case "Character[]": return Character[].class; case "Short[]": return Short[].class; case "Integer[]": return Integer[].class; case "Float[]": return Float[].class; case "Long[]": return Long[].class; case "Double[]": return Double[].class; case "Boolean[]": return Boolean[].class; case "String[]": return String[].class; default: return null; } } ArrayPreference(@NonNull final String key, @Nullable final T defValue); }
ArrayPreference extends SharedPreference<T> { static Class<?> resolveArrayClassByName(final String arrayClassName) { switch (arrayClassName) { case "byte[]": return byte[].class; case "char[]": return char[].class; case "short[]": return short[].class; case "int[]": return int[].class; case "float[]": return float[].class; case "long[]": return long[].class; case "double[]": return double[].class; case "boolean[]": return boolean[].class; case "Byte[]": return Byte[].class; case "Character[]": return Character[].class; case "Short[]": return Short[].class; case "Integer[]": return Integer[].class; case "Float[]": return Float[].class; case "Long[]": return Long[].class; case "Double[]": return Double[].class; case "Boolean[]": return Boolean[].class; case "String[]": return String[].class; default: return 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> { static Class<?> resolveArrayClassByName(final String arrayClassName) { switch (arrayClassName) { case "byte[]": return byte[].class; case "char[]": return char[].class; case "short[]": return short[].class; case "int[]": return int[].class; case "float[]": return float[].class; case "long[]": return long[].class; case "double[]": return double[].class; case "boolean[]": return boolean[].class; case "Byte[]": return Byte[].class; case "Character[]": return Character[].class; case "Short[]": return Short[].class; case "Integer[]": return Integer[].class; case "Float[]": return Float[].class; case "Long[]": return Long[].class; case "Double[]": return Double[].class; case "Boolean[]": return Boolean[].class; case "String[]": return String[].class; default: return 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);  }