001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.commons.collections;
018    
019    import java.util.Collection;
020    
021    /**
022     * Defines a collection that allows objects to be removed in some well-defined order.
023     * <p>
024     * The removal order can be based on insertion order (eg, a FIFO queue or a
025     * LIFO stack), on access order (eg, an LRU cache), on some arbitrary comparator
026     * (eg, a priority queue) or on any other well-defined ordering.
027     * <p>
028     * Note that the removal order is not necessarily the same as the iteration
029     * order.  A <code>Buffer</code> implementation may have equivalent removal
030     * and iteration orders, but this is not required.
031     * <p>
032     * This interface does not specify any behavior for 
033     * {@link Object#equals(Object)} and {@link Object#hashCode} methods.  It
034     * is therefore possible for a <code>Buffer</code> implementation to also
035     * also implement {@link java.util.List}, {@link java.util.Set} or 
036     * {@link Bag}.
037     * <p>
038     * <strong>Note:</strong> this class should be bytecode-identical to the 
039     * version in commons collections. This is required to allow backwards 
040     * compability with both previous versions of BeanUtils and also allow 
041     * coexistance with both collections 2.1 and 3.0.
042     *
043     * @since Commons Collections 2.1
044     * @version $Revision: 555824 $ $Date: 2007-07-13 01:27:15 +0100 (Fri, 13 Jul 2007) $
045     * 
046     * @author Avalon
047     * @author Berin Loritsch
048     * @author Paul Jack
049     * @author Stephen Colebourne
050     */
051    public interface Buffer extends Collection {
052    
053        /**
054         * Gets and removes the next object from the buffer.
055         *
056         * @return the next object in the buffer, which is also removed
057         * @throws BufferUnderflowException if the buffer is already empty
058         */
059        Object remove();
060    
061        /**
062         * Gets the next object from the buffer without removing it.
063         *
064         * @return the next object in the buffer, which is not removed
065         * @throws BufferUnderflowException if the buffer is empty
066         */
067        Object get();
068    
069    }