Coverage Summary for Class: ForwardingBlockingDeque (com.google.common.util.concurrent)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| ForwardingBlockingDeque | 0% (0/1) | 0% (0/16) | 0% (0/16) |
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.util.concurrent; 18 19 import com.google.common.annotations.GwtIncompatible; 20 import com.google.common.collect.ForwardingDeque; 21 import java.util.Collection; 22 import java.util.concurrent.BlockingDeque; 23 import java.util.concurrent.TimeUnit; 24 import javax.annotation.CheckForNull; 25 26 /** 27 * A {@link BlockingDeque} which forwards all its method calls to another {@code BlockingDeque}. 28 * Subclasses should override one or more methods to modify the behavior of the backing deque as 29 * desired per the <a href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>. 30 * 31 * <p><b>Warning:</b> The methods of {@code ForwardingBlockingDeque} forward <b>indiscriminately</b> 32 * to the methods of the delegate. For example, overriding {@link #add} alone <b>will not</b> change 33 * the behaviour of {@link #offer} which can lead to unexpected behaviour. In this case, you should 34 * override {@code offer} as well, either providing your own implementation, or delegating to the 35 * provided {@code standardOffer} method. 36 * 37 * <p><b>{@code default} method warning:</b> This class does <i>not</i> forward calls to {@code 38 * default} methods. Instead, it inherits their default implementations. When those implementations 39 * invoke methods, they invoke methods on the {@code ForwardingBlockingDeque}. 40 * 41 * <p>The {@code standard} methods are not guaranteed to be thread-safe, even when all of the 42 * methods that they depend on are thread-safe. 43 * 44 * @author Emily Soldal 45 * @since 21.0 (since 14.0 as {@link com.google.common.collect.ForwardingBlockingDeque}) 46 */ 47 @GwtIncompatible 48 @ElementTypesAreNonnullByDefault 49 public abstract class ForwardingBlockingDeque<E> extends ForwardingDeque<E> 50 implements BlockingDeque<E> { 51 52 /** Constructor for use by subclasses. */ 53 protected ForwardingBlockingDeque() {} 54 55 @Override 56 protected abstract BlockingDeque<E> delegate(); 57 58 @Override 59 public int remainingCapacity() { 60 return delegate().remainingCapacity(); 61 } 62 63 @Override 64 public void putFirst(E e) throws InterruptedException { 65 delegate().putFirst(e); 66 } 67 68 @Override 69 public void putLast(E e) throws InterruptedException { 70 delegate().putLast(e); 71 } 72 73 @Override 74 public boolean offerFirst(E e, long timeout, TimeUnit unit) throws InterruptedException { 75 return delegate().offerFirst(e, timeout, unit); 76 } 77 78 @Override 79 public boolean offerLast(E e, long timeout, TimeUnit unit) throws InterruptedException { 80 return delegate().offerLast(e, timeout, unit); 81 } 82 83 @Override 84 public E takeFirst() throws InterruptedException { 85 return delegate().takeFirst(); 86 } 87 88 @Override 89 public E takeLast() throws InterruptedException { 90 return delegate().takeLast(); 91 } 92 93 @Override 94 @CheckForNull 95 public E pollFirst(long timeout, TimeUnit unit) throws InterruptedException { 96 return delegate().pollFirst(timeout, unit); 97 } 98 99 @Override 100 @CheckForNull 101 public E pollLast(long timeout, TimeUnit unit) throws InterruptedException { 102 return delegate().pollLast(timeout, unit); 103 } 104 105 @Override 106 public void put(E e) throws InterruptedException { 107 delegate().put(e); 108 } 109 110 @Override 111 public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException { 112 return delegate().offer(e, timeout, unit); 113 } 114 115 @Override 116 public E take() throws InterruptedException { 117 return delegate().take(); 118 } 119 120 @Override 121 @CheckForNull 122 public E poll(long timeout, TimeUnit unit) throws InterruptedException { 123 return delegate().poll(timeout, unit); 124 } 125 126 @Override 127 public int drainTo(Collection<? super E> c) { 128 return delegate().drainTo(c); 129 } 130 131 @Override 132 public int drainTo(Collection<? super E> c, int maxElements) { 133 return delegate().drainTo(c, maxElements); 134 } 135 }