OffsetLagSeries extends OffsetSeries<T> { @Override public Series<T> shift(int offset, T filler) { return (offset < 0 && Objects.equals(filler, this.filler)) ? new OffsetLagSeries<>(delegate, this.offset + offset, filler) : super.shift(offset, filler); } OffsetLagSeries(Series<T> delegate, int offset, T filler); @Override Series<T> shift(int offset, T filler); @Override T get(int index); @Override void copyTo(Object[] to, int fromOffset, int toOffset, int len); @Override Series<T> materialize();  }
@Test public void testShift() { Series<String> s = new OffsetLagSeries<>(Series.forData("a", "b", "c", "d"), -1, "X"); new SeriesAsserts(s.shift(-1)).expectData("c", "d", "X", null); new SeriesAsserts(s.shift(-1, "X")).expectData("c", "d", "X", "X"); new SeriesAsserts(s.shift(-1, "Y")).expectData("c", "d", "X", "Y"); new SeriesAsserts(s.shift(1, "Y")).expectData("Y", "b", "c", "d"); new SeriesAsserts(s.shift(0, "Y")).expectData("b", "c", "d", "X"); }