|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.perfectjpattern.core.structural.AbstractSurrogate<T,A> org.perfectjpattern.core.structural.adapter.Adapter<Queue<E>,List<E>> org.perfectjpattern.core.structural.adapter.List2QueueAdapter<E>
E
- Type of the Queue
elementspublic class List2QueueAdapter<E>
Adapter that provides a Queue
based on a List
implementation.
That is, it adapts the List
to behave and look like a Queue
.
Please note that this is not an exhaustive implementation of Queue
nor it replaces the proper JDK Queue
implementations. The purpose
of this Adapter is only to demonstrate:
Adapter
implementation to adapt an
implementation to a given target interfaceremove()
, poll()
element()
peek()
IAdaptingStrategy
in this case
NameMatchAdaptingStrategy
where it maps e.g. offer(Object)
to ArrayList.add(Object)
Queue
interface methods e.g.
Collection.addAll(Collection)
or Collection.toArray()
as
the call forwarding is automatically handled by PerfectJPattern's
Adapter
Constructor Summary | |
---|---|
List2QueueAdapter(List<E> anAdaptee)
Constructs a List2QueueAdapter from the underlying Adaptee
List implementation. |
Method Summary | |
---|---|
E |
element()
Retrieves, but does not remove, the head of this queue. |
E |
peek()
Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty. |
E |
poll()
Retrieves and removes the head of this queue, or returns null if this queue is empty. |
E |
remove()
Retrieves and removes the head of this queue. |
Methods inherited from class org.perfectjpattern.core.structural.adapter.Adapter |
---|
getAdaptee, getTarget, invokeUnderlying, setAdaptingStrategy |
Methods inherited from class org.perfectjpattern.core.structural.AbstractSurrogate |
---|
equals, getComponent, getComponentClass, getUnderlying, hashCode, invoke |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.perfectjpattern.core.api.structural.ISurrogate |
---|
getComponent |
Methods inherited from interface java.lang.reflect.InvocationHandler |
---|
invoke |
Constructor Detail |
---|
public List2QueueAdapter(List<E> anAdaptee) throws IllegalArgumentException
List2QueueAdapter
from the underlying Adaptee
List
implementation.
anAdaptee
- The Adaptee List
implementation to adapt
IllegalArgumentException
- 'anAdaptee' must not be nullMethod Detail |
---|
public E remove() throws NoSuchElementException
poll
only in that it throws an exception if this
queue is empty.
NoSuchElementException
- if this queue is emptypublic E poll()
public E element()
peek
only in that it throws an exception
if this queue is empty.
NoSuchElementException
- if this queue is emptypublic E peek()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |