org.omnaest.utils.structure.collection.list.decorator
Class LockingListIteratorDecorator<E>

java.lang.Object
  extended by org.omnaest.utils.structure.collection.list.decorator.ListIteratorDecorator<E>
      extended by org.omnaest.utils.structure.collection.list.decorator.LockingListIteratorDecorator<E>
Type Parameters:
E -
All Implemented Interfaces:
Serializable, Iterator<E>, ListIterator<E>

public class LockingListIteratorDecorator<E>
extends ListIteratorDecorator<E>

A ListIteratorDecorator which uses a Lock to synchronize all of its methods.

Author:
Omnaest
See Also:
Serialized Form

Field Summary
protected  Lock lock
           
 
Fields inherited from class org.omnaest.utils.structure.collection.list.decorator.ListIteratorDecorator
listIterator
 
Constructor Summary
LockingListIteratorDecorator(ListIterator<E> listIterator)
          Uses a new ReentrantLock instance as Lock
LockingListIteratorDecorator(ListIterator<E> listIterator, Lock lock)
           
 
Method Summary
 void add(E e)
           
 boolean equals(Object obj)
           
 int hashCode()
           
 boolean hasNext()
           
 boolean hasPrevious()
           
 E next()
           
 int nextIndex()
           
 E previous()
           
 int previousIndex()
           
 void remove()
           
 void set(E e)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

lock

protected final Lock lock
Constructor Detail

LockingListIteratorDecorator

public LockingListIteratorDecorator(ListIterator<E> listIterator,
                                    Lock lock)
Parameters:
listIterator -
lock -
See Also:
LockingListIteratorDecorator

LockingListIteratorDecorator

public LockingListIteratorDecorator(ListIterator<E> listIterator)
Uses a new ReentrantLock instance as Lock

Parameters:
listIterator -
See Also:
LockingListIteratorDecorator
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<E>
Specified by:
hasNext in interface ListIterator<E>
Overrides:
hasNext in class ListIteratorDecorator<E>
See Also:
ListIterator.hasNext()

next

public E next()
Specified by:
next in interface Iterator<E>
Specified by:
next in interface ListIterator<E>
Overrides:
next in class ListIteratorDecorator<E>
See Also:
ListIterator.next()

hasPrevious

public boolean hasPrevious()
Specified by:
hasPrevious in interface ListIterator<E>
Overrides:
hasPrevious in class ListIteratorDecorator<E>
See Also:
ListIterator.hasPrevious()

previous

public E previous()
Specified by:
previous in interface ListIterator<E>
Overrides:
previous in class ListIteratorDecorator<E>
See Also:
ListIterator.previous()

nextIndex

public int nextIndex()
Specified by:
nextIndex in interface ListIterator<E>
Overrides:
nextIndex in class ListIteratorDecorator<E>
See Also:
ListIterator.nextIndex()

previousIndex

public int previousIndex()
Specified by:
previousIndex in interface ListIterator<E>
Overrides:
previousIndex in class ListIteratorDecorator<E>
See Also:
ListIterator.previousIndex()

remove

public void remove()
Specified by:
remove in interface Iterator<E>
Specified by:
remove in interface ListIterator<E>
Overrides:
remove in class ListIteratorDecorator<E>
See Also:
ListIterator.remove()

set

public void set(E e)
Specified by:
set in interface ListIterator<E>
Overrides:
set in class ListIteratorDecorator<E>
See Also:
ListIterator.set(java.lang.Object)

add

public void add(E e)
Specified by:
add in interface ListIterator<E>
Overrides:
add in class ListIteratorDecorator<E>
See Also:
ListIterator.add(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class ListIteratorDecorator<E>

equals

public boolean equals(Object obj)
Overrides:
equals in class ListIteratorDecorator<E>

toString

public String toString()
Overrides:
toString in class ListIteratorDecorator<E>


Copyright © 2013. All Rights Reserved.