StringListType implements Command, State { public String getValue(final int index) { if (index < 0 || index >= typeDetails.size()) { throw new IllegalArgumentException("Index is out of range"); } return typeDetails.get(index); } StringListType();  StringListType(List<String> rows);  StringListType(StringType... rows);  StringListType(String... rows);  StringListType(String serialized); String getValue(final int index); @Override String format(String pattern); @Override String toString(); @Override String toFullString(); static StringListType valueOf(String value); @Override int hashCode(); @Override boolean equals(@Nullable Object obj); static final String DELIMITER; static final String ESCAPED_DELIMITER; static final String REGEX_SPLITTER; }
@Test public void testWithEmptyConstituents() { StringListType call1 = new StringListType(",0699222222"); assertEquals("", call1.getValue(0)); assertEquals("0699222222", call1.getValue(1)); StringListType call2 = new StringListType("0699222222,"); assertEquals("0699222222", call2.getValue(0)); assertEquals("", call2.getValue(1)); }
@Test public void testError() { StringListType type = new StringListType("foo=bar", "electric", "chair"); try { @SuppressWarnings("unused") String value = type.getValue(-1); fail("-1 is an invalid index"); } catch (IllegalArgumentException e) { } try { @SuppressWarnings("unused") String value = type.getValue(3); fail("3 is an invalid index"); } catch (IllegalArgumentException e) { } }