@Test void testInsert() { StringTuple s = new StringTuple("2 3"); StringTuple changed = s.insert(0, "X"); assertEquals(changed, new StringTuple("X 2 3")); assertNotEquals(changed, s); }
public StringTuple insert(int index, String value) throws IndexOutOfBoundsException{ if( index < 0 || index >= items.size()) throw new IndexOutOfBoundsException(); List<String> copy = stringToItems(repr); copy.add(index, value); String modifiedRepr = joinList(" ", copy); return new StringTuple(modifiedRepr, copy); }
StringTuple implements Iterable<String> { public StringTuple insert(int index, String value) throws IndexOutOfBoundsException{ if( index < 0 || index >= items.size()) throw new IndexOutOfBoundsException(); List<String> copy = stringToItems(repr); copy.add(index, value); String modifiedRepr = joinList(" ", copy); return new StringTuple(modifiedRepr, copy); } }
StringTuple implements Iterable<String> { public StringTuple insert(int index, String value) throws IndexOutOfBoundsException{ if( index < 0 || index >= items.size()) throw new IndexOutOfBoundsException(); List<String> copy = stringToItems(repr); copy.add(index, value); String modifiedRepr = joinList(" ", copy); return new StringTuple(modifiedRepr, copy); } StringTuple(String s); private  StringTuple(String s, List<String> items); }
StringTuple implements Iterable<String> { public StringTuple insert(int index, String value) throws IndexOutOfBoundsException{ if( index < 0 || index >= items.size()) throw new IndexOutOfBoundsException(); List<String> copy = stringToItems(repr); copy.add(index, value); String modifiedRepr = joinList(" ", copy); return new StringTuple(modifiedRepr, copy); } StringTuple(String s); private  StringTuple(String s, List<String> items); static StringTuple fromParts(String ...parts); static StringTuple fromList(List<String> list); int size(); String get(int index); int find(ConditionFn fn); StringTuple modify(int index, ModifierFn fn); StringTuple remove(int index); StringTuple insert(int index, String value); @Override Iterator<String> iterator(); @Override int hashCode(); @Override boolean equals(Object other); @Override String toString(); static String joinList(String separator, List<S> list); }
StringTuple implements Iterable<String> { public StringTuple insert(int index, String value) throws IndexOutOfBoundsException{ if( index < 0 || index >= items.size()) throw new IndexOutOfBoundsException(); List<String> copy = stringToItems(repr); copy.add(index, value); String modifiedRepr = joinList(" ", copy); return new StringTuple(modifiedRepr, copy); } StringTuple(String s); private  StringTuple(String s, List<String> items); static StringTuple fromParts(String ...parts); static StringTuple fromList(List<String> list); int size(); String get(int index); int find(ConditionFn fn); StringTuple modify(int index, ModifierFn fn); StringTuple remove(int index); StringTuple insert(int index, String value); @Override Iterator<String> iterator(); @Override int hashCode(); @Override boolean equals(Object other); @Override String toString(); static String joinList(String separator, List<S> list);  }