MetadataValueAdapter implements MetadataValue { public boolean asBoolean() { Object value = value(); if (value instanceof Boolean) { return (Boolean) value; } if (value instanceof Number) { return ((Number) value).intValue() != 0; } if (value instanceof String) { return Boolean.parseBoolean((String) value); } return value != null; } protected  MetadataValueAdapter(Plugin owningPlugin); Plugin getOwningPlugin(); int asInt(); float asFloat(); double asDouble(); long asLong(); short asShort(); byte asByte(); boolean asBoolean(); String asString();  }
@Test public void testBooleanConversion() { assertEquals(false, simpleValue(null).asBoolean()); assertEquals(true, simpleValue("True").asBoolean()); assertEquals(true, simpleValue("TRUE").asBoolean()); assertEquals(false, simpleValue("false").asBoolean()); assertEquals(true, simpleValue(1).asBoolean()); assertEquals(true, simpleValue(5.0).asBoolean()); assertEquals(false, simpleValue(0).asBoolean()); assertEquals(false, simpleValue(0.1).asBoolean()); assertEquals(true, simpleValue(Boolean.TRUE).asBoolean()); assertEquals(false, simpleValue(Boolean.FALSE).asBoolean()); assertEquals(true, simpleValue(new Object()).asBoolean()); }