@Test public void testSwitchToMultiListenerMode() { final ObservableElementList<JLabel> list = new ObservableElementList<>(new BasicEventList<JLabel>(), new BurstOfThreeJLabelConnector()); for (int i = 0; i < 12; i++) { list.add(new JLabel()); } assertEquals(list.get(0).getPropertyChangeListeners().length, list.get(1).getPropertyChangeListeners().length); assertEquals(list.get(1).getPropertyChangeListeners().length, list.get(2).getPropertyChangeListeners().length); assertEquals(list.get(2).getPropertyChangeListeners().length+1, list.get(3).getPropertyChangeListeners().length); assertEquals(list.get(3).getPropertyChangeListeners().length, list.get(4).getPropertyChangeListeners().length); assertEquals(list.get(4).getPropertyChangeListeners().length, list.get(5).getPropertyChangeListeners().length); assertEquals(list.get(5).getPropertyChangeListeners().length-1, list.get(6).getPropertyChangeListeners().length); assertEquals(list.get(6).getPropertyChangeListeners().length, list.get(7).getPropertyChangeListeners().length); assertEquals(list.get(7).getPropertyChangeListeners().length, list.get(8).getPropertyChangeListeners().length); assertEquals(list.get(8).getPropertyChangeListeners().length+1, list.get(9).getPropertyChangeListeners().length); assertEquals(list.get(9).getPropertyChangeListeners().length, list.get(10).getPropertyChangeListeners().length); assertEquals(list.get(10).getPropertyChangeListeners().length, list.get(11).getPropertyChangeListeners().length); list.dispose(); for (Iterator<JLabel> i = list.iterator(); i.hasNext();) { assertEquals(list.get(0).getPropertyChangeListeners().length, i.next().getPropertyChangeListeners().length); } }
private void switchToMultiListenerMode() { if (!this.singleListenerMode) throw new IllegalStateException(); this.multiEventListenerRegistry = new ArrayList<>(this.source.size()); for (int i = 0; i < source.size(); i++) this.multiEventListenerRegistry.add(null); for (BarcodeIterator iter = this.singleEventListenerRegistry.iterator(); iter.hasNextBlack();) { iter.nextBlack(); this.multiEventListenerRegistry.set(iter.getIndex(), this.singleEventListener); } this.singleEventListener = null; this.singleEventListenerRegistry = null; this.singleListenerMode = false; }
ObservableElementList extends TransformedList<E, E> implements ObservableElementChangeHandler<E> { private void switchToMultiListenerMode() { if (!this.singleListenerMode) throw new IllegalStateException(); this.multiEventListenerRegistry = new ArrayList<>(this.source.size()); for (int i = 0; i < source.size(); i++) this.multiEventListenerRegistry.add(null); for (BarcodeIterator iter = this.singleEventListenerRegistry.iterator(); iter.hasNextBlack();) { iter.nextBlack(); this.multiEventListenerRegistry.set(iter.getIndex(), this.singleEventListener); } this.singleEventListener = null; this.singleEventListenerRegistry = null; this.singleListenerMode = false; } }
ObservableElementList extends TransformedList<E, E> implements ObservableElementChangeHandler<E> { private void switchToMultiListenerMode() { if (!this.singleListenerMode) throw new IllegalStateException(); this.multiEventListenerRegistry = new ArrayList<>(this.source.size()); for (int i = 0; i < source.size(); i++) this.multiEventListenerRegistry.add(null); for (BarcodeIterator iter = this.singleEventListenerRegistry.iterator(); iter.hasNextBlack();) { iter.nextBlack(); this.multiEventListenerRegistry.set(iter.getIndex(), this.singleEventListener); } this.singleEventListener = null; this.singleEventListenerRegistry = null; this.singleListenerMode = false; } ObservableElementList(EventList<E> source, Connector<? super E> elementConnector); }
ObservableElementList extends TransformedList<E, E> implements ObservableElementChangeHandler<E> { private void switchToMultiListenerMode() { if (!this.singleListenerMode) throw new IllegalStateException(); this.multiEventListenerRegistry = new ArrayList<>(this.source.size()); for (int i = 0; i < source.size(); i++) this.multiEventListenerRegistry.add(null); for (BarcodeIterator iter = this.singleEventListenerRegistry.iterator(); iter.hasNextBlack();) { iter.nextBlack(); this.multiEventListenerRegistry.set(iter.getIndex(), this.singleEventListener); } this.singleEventListener = null; this.singleEventListenerRegistry = null; this.singleListenerMode = false; } ObservableElementList(EventList<E> source, Connector<? super E> elementConnector); @Override void listChanged(ListEvent<E> listChanges); @Override void dispose(); @Override void elementChanged(Object listElement); }
ObservableElementList extends TransformedList<E, E> implements ObservableElementChangeHandler<E> { private void switchToMultiListenerMode() { if (!this.singleListenerMode) throw new IllegalStateException(); this.multiEventListenerRegistry = new ArrayList<>(this.source.size()); for (int i = 0; i < source.size(); i++) this.multiEventListenerRegistry.add(null); for (BarcodeIterator iter = this.singleEventListenerRegistry.iterator(); iter.hasNextBlack();) { iter.nextBlack(); this.multiEventListenerRegistry.set(iter.getIndex(), this.singleEventListener); } this.singleEventListener = null; this.singleEventListenerRegistry = null; this.singleListenerMode = false; } ObservableElementList(EventList<E> source, Connector<? super E> elementConnector); @Override void listChanged(ListEvent<E> listChanges); @Override void dispose(); @Override void elementChanged(Object listElement);  }