TextColumn extends AbstractStringColumn<TextColumn> { @Override public TextColumn lag(int n) { TextColumn copy = emptyCopy(); copy.setName(name() + " lag(" + n + ")"); if (n >= 0) { for (int m = 0; m < n; m++) { copy.appendCell(TextColumnType.missingValueIndicator()); } for (int i = 0; i < size(); i++) { if (i + n >= size()) { break; } copy.appendCell(get(i)); } } else { for (int i = -n; i < size(); i++) { copy.appendCell(get(i)); } for (int m = 0; m > n; m--) { copy.appendCell(TextColumnType.missingValueIndicator()); } } return copy; } private  TextColumn(String name, Collection<String> strings); private  TextColumn(String name); private  TextColumn(String name, String[] strings); static boolean valueIsMissing(String string); @Override TextColumn appendMissing(); static TextColumn create(String name); static TextColumn create(String name, String... strings); static TextColumn create(String name, Collection<String> strings); static TextColumn create(String name, int size); static TextColumn create(String name, Stream<String> stream); @Override boolean isMissing(int rowNumber); @Override TextColumn emptyCopy(); @Override TextColumn emptyCopy(int rowSize); @Override void sortAscending(); @Override void sortDescending(); @Override int size(); String get(int rowIndex); @Override List<String> asList(); @Override Table summary(); @Override void clear(); @Override TextColumn lead(int n); @Override TextColumn lag(int n); @Override TextColumn set(Selection rowSelection, String newValue); @Override TextColumn set(int rowIndex, String stringValue); @Override int countUnique(); @Override boolean contains(String aString); @Override TextColumn setMissing(int i); TextColumn addAll(List<String> stringValues); @Override TextColumn appendCell(String object); @Override TextColumn appendCell(String object, AbstractColumnParser<?> parser); @Override IntComparator rowComparator(); @Override boolean isEmpty(); @Override TextColumn unique(); TextColumn where(Selection selection); @Override TextColumn copy(); @Override TextColumn append(Column<String> column); @Override int countMissing(); @Override TextColumn removeMissing(); @Override Iterator<String> iterator(); Set<String> asSet(); @Override byte[] asBytes(int rowNumber); TextColumn append(String value); @Override TextColumn appendObj(Object obj); @Override Selection isIn(String... strings); @Override Selection isIn(Collection<String> strings); @Override Selection isNotIn(String... strings); @Override Selection isNotIn(Collection<String> strings); int firstIndexOf(String value); @Override String[] asObjectArray(); @Override StringColumn asStringColumn();  }
@Test public void lag() { TextColumn c1 = column.lag(1); Table t = Table.create("Test"); t.addColumns(column, c1); assertEquals("", c1.get(0)); assertEquals("Value 1", c1.get(1)); assertEquals("Value 2", c1.get(2)); }