Home | History | Annotate | Download | only in common
      1 package autotest.common;
      2 
      3 import java.util.AbstractList;
      4 import java.util.List;
      5 
      6 public class UnmodifiableSublistView<T> extends AbstractList<T> {
      7     protected List<T> backingList;
      8     protected int start, size;
      9 
     10     public UnmodifiableSublistView(List<T> list, int start, int size) {
     11         assert start >= 0;
     12         assert size >= 0;
     13         assert start + size <= list.size();
     14 
     15         this.backingList = list;
     16         this.start = start;
     17         this.size = size;
     18     }
     19 
     20     @Override
     21     public T get(int arg0) {
     22         if (arg0 >= size())
     23             throw new IndexOutOfBoundsException();
     24         return backingList.get(arg0 + start);
     25     }
     26 
     27     @Override
     28     public int size() {
     29         return this.size;
     30     }
     31 }
     32