Coverage Summary for Class: ForwardingDeque (com.google.common.collect)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| ForwardingDeque | 0% (0/1) | 0% (0/18) | 0% (0/18) |
1 /* 2 * Copyright (C) 2012 The Guava Authors 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.GwtIncompatible; 20 import com.google.errorprone.annotations.CanIgnoreReturnValue; 21 import java.util.Deque; 22 import java.util.Iterator; 23 24 /** 25 * A deque which forwards all its method calls to another deque. Subclasses should override one or 26 * more methods to modify the behavior of the backing deque as desired per the <a 27 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>. 28 * 29 * <p><b>Warning:</b> The methods of {@code ForwardingDeque} forward <b>indiscriminately</b> to the 30 * methods of the delegate. For example, overriding {@link #add} alone <b>will not</b> change the 31 * behavior of {@link #offer} which can lead to unexpected behavior. In this case, you should 32 * override {@code offer} as well. 33 * 34 * <p><b>{@code default} method warning:</b> This class does <i>not</i> forward calls to {@code 35 * default} methods. Instead, it inherits their default implementations. When those implementations 36 * invoke methods, they invoke methods on the {@code ForwardingDeque}. 37 * 38 * @author Kurt Alfred Kluever 39 * @since 12.0 40 */ 41 @GwtIncompatible 42 public abstract class ForwardingDeque<E> extends ForwardingQueue<E> implements Deque<E> { 43 44 /** Constructor for use by subclasses. */ 45 protected ForwardingDeque() {} 46 47 @Override 48 protected abstract Deque<E> delegate(); 49 50 @Override 51 public void addFirst(E e) { 52 delegate().addFirst(e); 53 } 54 55 @Override 56 public void addLast(E e) { 57 delegate().addLast(e); 58 } 59 60 @Override 61 public Iterator<E> descendingIterator() { 62 return delegate().descendingIterator(); 63 } 64 65 @Override 66 public E getFirst() { 67 return delegate().getFirst(); 68 } 69 70 @Override 71 public E getLast() { 72 return delegate().getLast(); 73 } 74 75 @CanIgnoreReturnValue // TODO(cpovirk): Consider removing this? 76 @Override 77 public boolean offerFirst(E e) { 78 return delegate().offerFirst(e); 79 } 80 81 @CanIgnoreReturnValue // TODO(cpovirk): Consider removing this? 82 @Override 83 public boolean offerLast(E e) { 84 return delegate().offerLast(e); 85 } 86 87 @Override 88 public E peekFirst() { 89 return delegate().peekFirst(); 90 } 91 92 @Override 93 public E peekLast() { 94 return delegate().peekLast(); 95 } 96 97 @CanIgnoreReturnValue // TODO(cpovirk): Consider removing this? 98 @Override 99 public E pollFirst() { 100 return delegate().pollFirst(); 101 } 102 103 @CanIgnoreReturnValue // TODO(cpovirk): Consider removing this? 104 @Override 105 public E pollLast() { 106 return delegate().pollLast(); 107 } 108 109 @CanIgnoreReturnValue 110 @Override 111 public E pop() { 112 return delegate().pop(); 113 } 114 115 @Override 116 public void push(E e) { 117 delegate().push(e); 118 } 119 120 @CanIgnoreReturnValue 121 @Override 122 public E removeFirst() { 123 return delegate().removeFirst(); 124 } 125 126 @CanIgnoreReturnValue 127 @Override 128 public E removeLast() { 129 return delegate().removeLast(); 130 } 131 132 @CanIgnoreReturnValue 133 @Override 134 public boolean removeFirstOccurrence(Object o) { 135 return delegate().removeFirstOccurrence(o); 136 } 137 138 @CanIgnoreReturnValue 139 @Override 140 public boolean removeLastOccurrence(Object o) { 141 return delegate().removeLastOccurrence(o); 142 } 143 }