Resource { @Nullable protected Boolean getAsNonPrimitiveBoolean() { try { return (Boolean) value; } catch (ClassCastException e) { return null; } } 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 testGetAsNonPrimitiveBoolean() throws Exception { assertEquals(RESOURCE_BOOLEAN.getAsNonPrimitiveBoolean(), Boolean.valueOf(true)); assertEquals(RESOURCE_FLOAT.getAsNonPrimitiveBoolean(), null); }