Class TestInbox

  • All Implemented Interfaces:
    Inbox, java.lang.Iterable<java.lang.Object>

    public final class TestInbox
    extends java.lang.Object
    implements Inbox
    Inbox implementation suitable to be used in tests.
    Since:
    Jet 3.0
    • Constructor Summary

      Constructors 
      Constructor Description
      TestInbox()
      Constructs the inbox.
      TestInbox​(java.util.Collection<?> collection)
      Convenience for new TestInbox().queue().addAll(o)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.Object o)
      Convenience for inbox.queue().add(o)
      void addAll​(java.util.Collection<?> collection)
      Convenience for inbox.queue().addAll(collection)
      void clear()
      Convenience for inbox.queue().clear()
      boolean isEmpty()
      Returns true if this inbox contains no elements, false otherwise.
      java.util.Iterator<java.lang.Object> iterator()
      Returns an iterator over the items in the inbox in the order they would be returned by the Inbox.poll() method.
      java.lang.Object peek()
      Retrieves, but does not remove, the head of this inbox, or returns null if it is empty.
      java.lang.Object poll()
      Retrieves and removes the head of this inbox, or returns null if it is empty.
      java.util.Deque<java.lang.Object> queue()
      Retrieves the queue backing the inbox.
      void remove()
      Removes the head of this inbox.
      int size()
      Convenience for inbox.queue().size()
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • TestInbox

        public TestInbox()
        Constructs the inbox.
      • TestInbox

        public TestInbox​(java.util.Collection<?> collection)
        Convenience for new TestInbox().queue().addAll(o)
    • Method Detail

      • isEmpty

        public boolean isEmpty()
        Description copied from interface: Inbox
        Returns true if this inbox contains no elements, false otherwise.
        Specified by:
        isEmpty in interface Inbox
      • peek

        public java.lang.Object peek()
        Description copied from interface: Inbox
        Retrieves, but does not remove, the head of this inbox, or returns null if it is empty.
        Specified by:
        peek in interface Inbox
      • poll

        public java.lang.Object poll()
        Description copied from interface: Inbox
        Retrieves and removes the head of this inbox, or returns null if it is empty.
        Specified by:
        poll in interface Inbox
      • remove

        public void remove()
        Description copied from interface: Inbox
        Removes the head of this inbox. This method throws an exception if the inbox is empty.
        Specified by:
        remove in interface Inbox
      • queue

        public java.util.Deque<java.lang.Object> queue()
        Retrieves the queue backing the inbox.
      • add

        public void add​(java.lang.Object o)
        Convenience for inbox.queue().add(o)
      • addAll

        public void addAll​(java.util.Collection<?> collection)
        Convenience for inbox.queue().addAll(collection)
      • iterator

        @Nonnull
        public java.util.Iterator<java.lang.Object> iterator()
        Description copied from interface: Inbox
        Returns an iterator over the items in the inbox in the order they would be returned by the Inbox.poll() method.

        The returned iterator doesn't support the Iterator.remove() method.

        Specified by:
        iterator in interface Inbox
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.Object>
      • clear

        public void clear()
        Convenience for inbox.queue().clear()
        Specified by:
        clear in interface Inbox
      • size

        public int size()
        Convenience for inbox.queue().size()
        Specified by:
        size in interface Inbox
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object