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 */
017package org.apache.commons.collections4.queue;
018
019import java.util.Queue;
020
021import org.apache.commons.collections4.collection.AbstractCollectionDecorator;
022
023/**
024 * Decorates another {@link Queue} to provide additional behaviour.
025 * <p>
026 * Methods are forwarded directly to the decorated queue.
027 *
028 * @param <E> the type of the elements in the queue
029 * @since 4.0
030 * @version $Id: AbstractQueueDecorator.html 972421 2015-11-14 20:00:04Z tn $
031 */
032public abstract class AbstractQueueDecorator<E> extends AbstractCollectionDecorator<E>
033        implements Queue<E> {
034
035    /** Serialization version */
036    private static final long serialVersionUID = -2629815475789577029L;
037
038    /**
039     * Constructor only used in deserialization, do not use otherwise.
040     */
041    protected AbstractQueueDecorator() {
042        super();
043    }
044
045    /**
046     * Constructor that wraps (not copies).
047     *
048     * @param queue  the queue to decorate, must not be null
049     * @throws IllegalArgumentException if list is null
050     */
051    protected AbstractQueueDecorator(final Queue<E> queue) {
052        super(queue);
053    }
054
055    /**
056     * Gets the queue being decorated.
057     *
058     * @return the decorated queue
059     */
060    @Override
061    protected Queue<E> decorated() {
062        return (Queue<E>) super.decorated();
063    }
064
065    //-----------------------------------------------------------------------
066
067    public boolean offer(final E obj) {
068        return decorated().offer(obj);
069    }
070
071    public E poll() {
072        return decorated().poll();
073    }
074
075    public E peek() {
076        return decorated().peek();
077    }
078
079    public E element() {
080        return decorated().element();
081    }
082
083    public E remove() {
084        return decorated().remove();
085    }
086
087}