Resource { public boolean getAsBoolean() { if (isBoolean() && null != getAsNonPrimitiveBoolean()) { return getAsNonPrimitiveBoolean(); } else { return Boolean.parseBoolean(getAsString()); } } 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 testGetAsBoolean() throws Exception { assertEquals(RESOURCE_BOOLEAN.getAsBoolean(), true); assertEquals(RESOURCE_STRING.getAsBoolean(), false); assertEquals(RESOURCE_FLOAT.getAsBoolean(), false); assertEquals(RESOURCE_INTEGER.getAsBoolean(), false); assertEquals(RESOURCE_ARRAY.getAsBoolean(), false); assertEquals(new Resource("true").getAsBoolean(), true); }