OffsetLeadSeries extends OffsetSeries<T> { @Override public Series<T> shift(int offset, T filler) { return (offset > 0 && Objects.equals(filler, this.filler)) ? new OffsetLeadSeries<>(delegate, this.offset + offset, filler) : super.shift(offset, filler); } OffsetLeadSeries(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 OffsetLeadSeries<>(Series.forData("a", "b", "c", "d"), 1, "X"); new SeriesAsserts(s.shift(-1)).expectData("a", "b", "c", null); new SeriesAsserts(s.shift(-1, "X")).expectData("a", "b", "c", "X"); new SeriesAsserts(s.shift(-1, "Y")).expectData("a", "b", "c", "Y"); new SeriesAsserts(s.shift(1, "X")).expectData("X", "X", "a", "b"); new SeriesAsserts(s.shift(1, "Y")).expectData("Y", "X", "a", "b"); new SeriesAsserts(s.shift(0, "Y")).expectData("X", "a", "b", "c"); }