/** * Returns a new empty {@link DebugList} which shares the same * {@link ListEventListener} and {@link ReadWriteLock} with this DebugList. * This method is particularly useful when debugging a {@link CompositeList} * where some member lists are DebugLists and thus must share an identical * publisher and locks in order to participate in the CompositeList. */ public <E> DebugList<E> createNewDebugList() { return new DebugList<E>(getPublisher(), debugReadWriteLock); }
/** {@inheritDoc} */ @Override public boolean equals(Object object) { beforeReadOperation(); try { return delegate.equals(object); } finally { afterReadOperation(); } }
/** {@inheritDoc} */ @Override public boolean add(E value) { beforeWriteOperation(); try { return delegate.add(value); } finally { afterWriteOperation(); } }
/** * This generic method is called immediately before any read operation is * invoked. All generic read assertions should take place here. */ protected void beforeReadOperation() { // if a Set of reader Threads have been given, ensure the current Thread is one of them if (!sanctionedReaderThreads.isEmpty() && !sanctionedReaderThreads.contains(Thread.currentThread())) throw new IllegalStateException("DebugList detected an unexpected Thread (" + Thread.currentThread() + ") attempting to perform a read operation"); // if lock checking is enabled, ensure the current Thread holds a read or write lock before continuing if (isLockCheckingEnabled() && !debugReadWriteLock.isThreadHoldingReadOrWriteLock()) throw new IllegalStateException("DebugList detected a failure to acquire the readLock prior to a read operation"); }
public EventList<E> create() { if (Program.isDebug()) { DebugList<E> debugList = new DebugList<E>(); debugList.setLockCheckingEnabled(true); return debugList; } else { return new BasicEventList<E>(); } } public static <E> List<E> safeList(EventList<E> eventList) {
/** * This generic method is called immediately before any write operation is * invoked. All generic write assertions should take place here. */ protected void beforeWriteOperation() { // if a Set of writer Threads have been given, ensure the current Thread is one of them if (!sanctionedWriterThreads.isEmpty() && !sanctionedWriterThreads.contains(Thread.currentThread())) throw new IllegalStateException("DebugList detected an unexpected Thread (" + Thread.currentThread() + ") attempting to perform a write operation"); // if lock checking is enabled, ensure the current Thread holds a write lock before continuing if (isLockCheckingEnabled() && !debugReadWriteLock.isThreadHoldingWriteLock()) throw new IllegalStateException("DebugList detected a failure to acquire the writeLock prior to a write operation"); }
/** {@inheritDoc} */ @Override public boolean equals(Object object) { beforeReadOperation(); try { return delegate.equals(object); } finally { afterReadOperation(); } }
/** {@inheritDoc} */ @Override public E set(int index, E value) { beforeWriteOperation(); try { return delegate.set(index, value); } finally { afterWriteOperation(); } }
/** * Returns a new empty {@link DebugList} which shares the same * {@link ListEventListener} and {@link ReadWriteLock} with this DebugList. * This method is particularly useful when debugging a {@link CompositeList} * where some member lists are DebugLists and thus must share an identical * publisher and locks in order to participate in the CompositeList. */ public <E> DebugList<E> createNewDebugList() { return new DebugList<E>(getPublisher(), debugReadWriteLock); }
/** * This generic method is called immediately before any write operation is * invoked. All generic write assertions should take place here. */ protected void beforeWriteOperation() { // if a Set of writer Threads have been given, ensure the current Thread is one of them if (!sanctionedWriterThreads.isEmpty() && !sanctionedWriterThreads.contains(Thread.currentThread())) throw new IllegalStateException("DebugList detected an unexpected Thread (" + Thread.currentThread() + ") attempting to perform a write operation"); // if lock checking is enabled, ensure the current Thread holds a write lock before continuing if (isLockCheckingEnabled() && !debugReadWriteLock.isThreadHoldingWriteLock()) throw new IllegalStateException("DebugList detected a failure to acquire the writeLock prior to a write operation"); }
/** {@inheritDoc} */ @Override public String toString() { beforeReadOperation(); try { return delegate.toString(); } finally { afterReadOperation(); } }
/** {@inheritDoc} */ @Override public E remove(int index) { beforeWriteOperation(); try { return delegate.remove(index); } finally { afterWriteOperation(); } }
/** * Returns a new empty {@link DebugList} which shares the same * {@link ListEventListener} and {@link ReadWriteLock} with this DebugList. * This method is particularly useful when debugging a {@link CompositeList} * where some member lists are DebugLists and thus must share an identical * publisher and locks in order to participate in the CompositeList. */ public <E> DebugList<E> createNewDebugList() { return new DebugList<E>(getPublisher(), debugReadWriteLock); }
/** * This generic method is called immediately before any write operation is * invoked. All generic write assertions should take place here. */ protected void beforeWriteOperation() { // if a Set of writer Threads have been given, ensure the current Thread is one of them if (!sanctionedWriterThreads.isEmpty() && !sanctionedWriterThreads.contains(Thread.currentThread())) throw new IllegalStateException("DebugList detected an unexpected Thread (" + Thread.currentThread() + ") attempting to perform a write operation"); // if lock checking is enabled, ensure the current Thread holds a write lock before continuing if (isLockCheckingEnabled() && !debugReadWriteLock.isThreadHoldingWriteLock()) throw new IllegalStateException("DebugList detected a failure to acquire the writeLock prior to a write operation"); }
/** {@inheritDoc} */ @Override public int hashCode() { beforeReadOperation(); try { return delegate.hashCode(); } finally { afterReadOperation(); } }
/** {@inheritDoc} */ @Override public boolean add(E value) { beforeWriteOperation(); try { return delegate.add(value); } finally { afterWriteOperation(); } }
/** * This generic method is called immediately before any read operation is * invoked. All generic read assertions should take place here. */ protected void beforeReadOperation() { // if a Set of reader Threads have been given, ensure the current Thread is one of them if (!sanctionedReaderThreads.isEmpty() && !sanctionedReaderThreads.contains(Thread.currentThread())) throw new IllegalStateException("DebugList detected an unexpected Thread (" + Thread.currentThread() + ") attempting to perform a read operation"); // if lock checking is enabled, ensure the current Thread holds a read or write lock before continuing if (isLockCheckingEnabled() && !debugReadWriteLock.isThreadHoldingReadOrWriteLock()) throw new IllegalStateException("DebugList detected a failure to acquire the readLock prior to a read operation"); }
/** {@inheritDoc} */ @Override public boolean equals(Object object) { beforeReadOperation(); try { return delegate.equals(object); } finally { afterReadOperation(); } }
/** {@inheritDoc} */ @Override public E remove(int index) { beforeWriteOperation(); try { return delegate.remove(index); } finally { afterWriteOperation(); } }
/** * This generic method is called immediately before any read operation is * invoked. All generic read assertions should take place here. */ protected void beforeReadOperation() { // if a Set of reader Threads have been given, ensure the current Thread is one of them if (!sanctionedReaderThreads.isEmpty() && !sanctionedReaderThreads.contains(Thread.currentThread())) throw new IllegalStateException("DebugList detected an unexpected Thread (" + Thread.currentThread() + ") attempting to perform a read operation"); // if lock checking is enabled, ensure the current Thread holds a read or write lock before continuing if (isLockCheckingEnabled() && !debugReadWriteLock.isThreadHoldingReadOrWriteLock()) throw new IllegalStateException("DebugList detected a failure to acquire the readLock prior to a read operation"); }