RequestParameter extends Parameter<String> { public boolean toBoolean() { String value = toString(); return BooleanUtils.toBoolean(value); } RequestParameter(String name, String value); boolean isBlank(); @Override boolean isEmpty(); @Override RequestParameter validateWith(ValidationStrategy<String> validationStrategy); @Override String toString(); String toString(String defaultValue); Double toDouble(); Double toDouble(double defaultValue); Long toLong(); Long toLong(long defaultValue); Integer toInteger(); Integer toInteger(int defaultValue); boolean toBoolean(); boolean toBoolean(boolean defaultValue); E toEnum(Class<E> type); E toEnum(Class<E> type, E defaultValue);  }
@Test public void testToBooleanWithValidValues() throws Exception { assertEquals(true, new RequestParameter(null, "true").toBoolean()); assertEquals(true, new RequestParameter(null, "TRUE").toBoolean()); assertEquals(true, new RequestParameter(null, "yes").toBoolean()); assertEquals(true, new RequestParameter(null, "YES").toBoolean()); assertEquals(false, new RequestParameter(null, "false").toBoolean()); assertEquals(false, new RequestParameter(null, "no").toBoolean()); assertEquals(false, new RequestParameter(null, "1").toBoolean()); assertEquals(false, new RequestParameter(null, "0").toBoolean()); assertEquals(false, new RequestParameter(null, "foo").toBoolean()); }