Resource { @NonNull public String[] getAsStringArray() { if (isArray()) { Resource[] resources = getAsArray(); String[] strings = new String[resources.length]; for (int i = 0; i < resources.length; i++) { Resource resource = resources[i]; strings[i] = resource.getAsString(); } return strings; } else if (null != getAsString()) { return getAsString().split("(?!^)"); } else { return new String[] {}; } } Resource(Boolean value);  Resource(Number value);  Resource(String value);  Resource(Resource[] value); boolean isBoolean(); boolean isNumber(); boolean isString(); boolean isArray(); boolean getAsBoolean(); @Nullable String getAsString(); @Nullable Float getAsFloat(); @Nullable Integer getAsInt(); int[] getAsIntegerArray(); @NonNull String[] getAsStringArray();  }
@Test public void testGetAsStringArray() throws Exception { assertEquals(RESOURCE_BOOLEAN.getAsStringArray().length, 4); assertEquals(RESOURCE_STRING.getAsStringArray().length, 3); assertEquals(RESOURCE_FLOAT.getAsStringArray().length, 3); assertEquals(RESOURCE_INTEGER.getAsStringArray().length, 1); assertEquals(RESOURCE_ARRAY.getAsStringArray().length, 0); assertEquals( new Resource(new Resource[] { RESOURCE_INTEGER, RESOURCE_FLOAT }).getAsStringArray().length, 2); assertEquals( new Resource(new Resource[] { RESOURCE_INTEGER, RESOURCE_FLOAT }).getAsStringArray()[0], "1"); assertEquals( new Resource(new Resource[] { RESOURCE_INTEGER, RESOURCE_FLOAT }).getAsStringArray()[1], "2.0"); assertEquals(new Resource((Resource[]) null).getAsStringArray().length, 0); }