MessageQueue.java
01 /*
02  *  Licensed to the Apache Software Foundation (ASF) under one
03  *  or more contributor license agreements.  See the NOTICE file
04  *  distributed with this work for additional information
05  *  regarding copyright ownership.  The ASF licenses this file
06  *  to you under the Apache License, Version 2.0 (the
07  *  "License"); you may not use this file except in compliance
08  *  with the License.  You may obtain a copy of the License at
09  *
10  *    http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing,
13  *  software distributed under the License is distributed on an
14  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  *  KIND, either express or implied.  See the License for the
16  *  specific language governing permissions and limitations
17  *  under the License.
18  *
19  *
20  */
21 package org.apache.qpid.util;
22 
23 import java.util.Queue;
24 
25 /**
26  * Defines a queue that has a push operation to add an element to the head of the queue.
27  *
28  * @todo Seems like this may be pointless, the implementation uses this method to increment the message count
29  *       then calls offer. Why not simply override offer and drop this interface?
30  */
31 public interface MessageQueue<E> extends Queue<E>
32 {
33     /**
34      * Inserts the specified element into this queue, if possible. When using queues that may impose insertion
35      * restrictions (for example capacity bounds), method offer is generally preferable to method Collection.add(E),
36      * which can fail to insert an element only by throwing an exception.
37      *
38      @param o The element to insert.
39      *
40      @return <tt>true</tt> if it was possible to add the element to this queue, else <tt>false</tt>
41      */
42     boolean pushHead(E o);
43 }