OffsetLagSeries extends OffsetSeries<T> { @Override public Series<T> materialize() { int size = size(); int splitPoint = size + offset; Object[] buffer = new Object[size]; delegate.copyTo(buffer, -offset, 0, splitPoint); if (filler != null) { Arrays.fill(buffer, splitPoint, size, filler); } return new ArraySeries<>((T[]) buffer); } 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 testMaterialize() { Series<String> s = new OffsetLagSeries<>(Series.forData("a", "b", "c", "d"), -1, "X").materialize(); assertTrue(s instanceof ArraySeries); new SeriesAsserts(s).expectData("b", "c", "d", "X"); }