Resource { public int[] getAsIntegerArray() { if (isArray()) { Resource[] resources = getAsArray(); int[] integers = new int[resources.length]; for (int i = 0; i < resources.length; i++) { Resource resource = resources[i]; if (null != resource.getAsInt()) { integers[i] = resource.getAsInt(); } } return integers; } else { return new int[] {}; } } 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 testGetAsIntegerArray() throws Exception { assertEquals(RESOURCE_BOOLEAN.getAsIntegerArray().length, 0); assertEquals(RESOURCE_STRING.getAsIntegerArray().length, 0); assertEquals(RESOURCE_FLOAT.getAsIntegerArray().length, 0); assertEquals(RESOURCE_INTEGER.getAsIntegerArray().length, 0); assertEquals(RESOURCE_ARRAY.getAsIntegerArray().length, 0); assertEquals(new Resource( new Resource[] { RESOURCE_INTEGER, RESOURCE_FLOAT }).getAsIntegerArray().length, 2); assertEquals( new Resource(new Resource[] { RESOURCE_INTEGER, RESOURCE_FLOAT }).getAsIntegerArray()[0], 1); assertEquals( new Resource(new Resource[] { RESOURCE_INTEGER, RESOURCE_FLOAT }).getAsIntegerArray()[1], 2); }