OffsetLeadSeries extends OffsetSeries<T> { @Override public T get(int index) { int size = size(); if (index >= size || index < 0) { throw new ArrayIndexOutOfBoundsException(index); } return index < offset ? filler : delegate.get(index - offset); } 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 testGet() { Series<String> s = new OffsetLeadSeries<>(Series.forData("a", "b", "c", "d"), 1, "X"); assertThrows(ArrayIndexOutOfBoundsException.class, () -> s.get(-1)); assertEquals("X", s.get(0)); assertEquals("a", s.get(1)); assertEquals("b", s.get(2)); assertEquals("c", s.get(3)); assertThrows(ArrayIndexOutOfBoundsException.class, () -> s.get(4)); }