RequestParameter extends Parameter<String> { public Long toLong() { String value = toString(); try { return Long.parseLong(value); } catch (NumberFormatException e) { throw new InvalidRequestParameterException(getName(), 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 testToLongerWithValidValues() throws Exception { assertEquals(Long.valueOf(1), new RequestParameter(null, "1").toLong()); assertEquals(Long.valueOf(-1), new RequestParameter(null, "-1").toLong()); }