@Test public void testGetElementAt() { EventList<Color> colors = new BasicEventList<>(); colors.add(Color.RED); colors.add(Color.GREEN); colors.add(Color.BLUE); DefaultEventListModel<Color> listModel = new DefaultEventListModel<>(colors); assertEquals(Color.RED, listModel.getElementAt(0)); assertEquals(Color.GREEN, listModel.getElementAt(1)); assertEquals(Color.BLUE, listModel.getElementAt(2)); try { listModel.getElementAt(100); fail("failed to receive IndexOutOfBoundsException for invalid index"); } catch (IndexOutOfBoundsException e) { } try { listModel.getElementAt(-1); fail("failed to receive IndexOutOfBoundsException for invalid index"); } catch (IndexOutOfBoundsException e) { } }
@Override public E getElementAt(int index) { source.getReadWriteLock().readLock().lock(); try { return source.get(index); } finally { source.getReadWriteLock().readLock().unlock(); } }
DefaultEventListModel implements ListEventListener<E>, ListModel<E> { @Override public E getElementAt(int index) { source.getReadWriteLock().readLock().lock(); try { return source.get(index); } finally { source.getReadWriteLock().readLock().unlock(); } } }
DefaultEventListModel implements ListEventListener<E>, ListModel<E> { @Override public E getElementAt(int index) { source.getReadWriteLock().readLock().lock(); try { return source.get(index); } finally { source.getReadWriteLock().readLock().unlock(); } } DefaultEventListModel(EventList<E> source);  DefaultEventListModel(EventList<E> source, boolean disposeSource); }
DefaultEventListModel implements ListEventListener<E>, ListModel<E> { @Override public E getElementAt(int index) { source.getReadWriteLock().readLock().lock(); try { return source.get(index); } finally { source.getReadWriteLock().readLock().unlock(); } } DefaultEventListModel(EventList<E> source);  DefaultEventListModel(EventList<E> source, boolean disposeSource); @Override void listChanged(ListEvent<E> listChanges); @Override E getElementAt(int index); @Override int getSize(); @Override void addListDataListener(ListDataListener listDataListener); @Override void removeListDataListener(ListDataListener listDataListener); void dispose(); }
DefaultEventListModel implements ListEventListener<E>, ListModel<E> { @Override public E getElementAt(int index) { source.getReadWriteLock().readLock().lock(); try { return source.get(index); } finally { source.getReadWriteLock().readLock().unlock(); } } DefaultEventListModel(EventList<E> source);  DefaultEventListModel(EventList<E> source, boolean disposeSource); @Override void listChanged(ListEvent<E> listChanges); @Override E getElementAt(int index); @Override int getSize(); @Override void addListDataListener(ListDataListener listDataListener); @Override void removeListDataListener(ListDataListener listDataListener); void dispose();  }