1 /* 2 * Copyright (C) 2007 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.common.collect; 18 19 import com.google.common.annotations.GwtCompatible; 20 21 import java.util.Queue; 22 23 /** 24 * A queue which forwards all its method calls to another queue. Subclasses 25 * should override one or more methods to modify the behavior of the backing 26 * queue as desired per the <a 27 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>. 28 * 29 * @see ForwardingObject 30 * @author Mike Bostock 31 * @since 2010.01.04 <b>stable</b> (imported from Google Collections Library) 32 */ 33 @GwtCompatible 34 public abstract class ForwardingQueue<E> extends ForwardingCollection<E> 35 implements Queue<E> { 36 37 @Override protected abstract Queue<E> delegate(); 38 39 public boolean offer(E o) { 40 return delegate().offer(o); 41 } 42 43 public E poll() { 44 return delegate().poll(); 45 } 46 47 public E remove() { 48 return delegate().remove(); 49 } 50 51 public E peek() { 52 return delegate().peek(); 53 } 54 55 public E element() { 56 return delegate().element(); 57 } 58 } 59