Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.gh.bmd.jrt.routine;
Interface defining a queue with the possibility to add nested queues with additional elements.

This interface is used to abstract the handling of placeholders for asynchronously available data, in order to support forced input and output ordering.

Created by davide on 9/30/14.

Parameters:
<E> the element type.
interface NestedQueue<E> {

    
Adds the specified element to the queue.

Note that the element can be null.

Parameters:
element the element to add.
Throws:
java.lang.IllegalStateException if the queue has been already closed.
    void add(@Nullable E element);

    
Adds all the elements returned by the specified iterable.

Note that the any of the returned element can be null.

Parameters:
elements the element iterable.
Throws:
java.lang.IllegalStateException if the queue has been already closed.
    void addAll(@Nonnull Iterable<? extends E> elements);

    
Adds a nested queue to this one.

Returns:
the newly added nested queue.
Throws:
java.lang.IllegalStateException if the queue has been already closed.
    @Nonnull
    NestedQueue<E> addNested();

    
Clears the queue.
    void clear();

    
Closes this queue.
After the method returns no further additions can be made to this queue. Though, elements can be safely removed.
    void close();

    
Check if the queue does not contain any element.

Returns:
whether the queue is empty.
    boolean isEmpty();

    
Moves all the elements to the specified collection.

Parameters:
collection the collection to fill.
    void moveTo(@Nonnull final Collection<? super E> collection);

    
Removes the first element added into the queue.

Returns:
the element.
Throws:
java.util.NoSuchElementException if the queue is empty.
    @Nullable
    E removeFirst();
New to GrepCode? Check out our FAQ X