@Test public void testBoundsErrorBehaviour() { boolean exceptionThrown = false; try { cache.get(26); } catch(IndexOutOfBoundsException e) { exceptionThrown = true; } if(exceptionThrown == false) { fail("No exception was thrown when an invalid index was requested on an empty source."); } for(int i = 0;i < 25;i++) { source.add(new Integer(i)); } exceptionThrown = false; try { cache.get(26); } catch(IndexOutOfBoundsException e) { exceptionThrown = true; } if(exceptionThrown == false) { fail("No exception was thrown when an invalid index was requested on an empty cache."); } for(int i = 9;i < 15;i++) { Object result = cache.get(i); assertEquals(new Integer(i), result); } exceptionThrown = false; try { cache.get(26); } catch(IndexOutOfBoundsException e) { exceptionThrown = true; } if(exceptionThrown == false) { fail("No exception was thrown when an invalid index was requested on a partially full cache."); } for(int i = 9;i < 15;i++) { Object result = cache.get(i); assertEquals(new Integer(i), result); } exceptionThrown = false; try { cache.get(26); } catch(IndexOutOfBoundsException e) { exceptionThrown = true; } if(!exceptionThrown) { fail("No exception was thrown when an invalid index was requested on a full cache."); } }
@Override public final Object get(int index) { if(index >= size()) throw new IndexOutOfBoundsException("cannot get from tree of size " + size() + " at " + index); preFetch(index); return fetch(index, true); }
CachingList extends TransformedList { @Override public final Object get(int index) { if(index >= size()) throw new IndexOutOfBoundsException("cannot get from tree of size " + size() + " at " + index); preFetch(index); return fetch(index, true); } }
CachingList extends TransformedList { @Override public final Object get(int index) { if(index >= size()) throw new IndexOutOfBoundsException("cannot get from tree of size " + size() + " at " + index); preFetch(index); return fetch(index, true); } CachingList(EventList source, int maxSize); }
CachingList extends TransformedList { @Override public final Object get(int index) { if(index >= size()) throw new IndexOutOfBoundsException("cannot get from tree of size " + size() + " at " + index); preFetch(index); return fetch(index, true); } CachingList(EventList source, int maxSize); @Override final int size(); @Override final Object get(int index); final int getCacheHits(); final int getCacheMisses(); final float getCacheHitRatio(); @Override final void listChanged(ListEvent listChanges); }
CachingList extends TransformedList { @Override public final Object get(int index) { if(index >= size()) throw new IndexOutOfBoundsException("cannot get from tree of size " + size() + " at " + index); preFetch(index); return fetch(index, true); } CachingList(EventList source, int maxSize); @Override final int size(); @Override final Object get(int index); final int getCacheHits(); final int getCacheMisses(); final float getCacheHitRatio(); @Override final void listChanged(ListEvent listChanges);  }