Home | History | Annotate | Download | only in async
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      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.android.camera.async;
     18 
     19 import java.util.concurrent.TimeUnit;
     20 import java.util.concurrent.TimeoutException;
     21 
     22 /**
     23  * A BufferQueue which forwards all methods to another.
     24  */
     25 public abstract class ForwardingBufferQueue<T> implements BufferQueue<T> {
     26     private final BufferQueue<T> mDelegate;
     27 
     28     public ForwardingBufferQueue(BufferQueue<T> delegate) {
     29         mDelegate = delegate;
     30     }
     31 
     32     @Override
     33     public void close() {
     34         mDelegate.close();
     35     }
     36 
     37     @Override
     38     public T getNext() throws InterruptedException, BufferQueueClosedException {
     39         return mDelegate.getNext();
     40     }
     41 
     42     @Override
     43     public T getNext(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException,
     44             BufferQueueClosedException {
     45         return mDelegate.getNext(timeout, unit);
     46     }
     47 
     48     @Override
     49     public T peekNext() {
     50         return mDelegate.peekNext();
     51     }
     52 
     53     @Override
     54     public void discardNext() {
     55         mDelegate.discardNext();
     56     }
     57 
     58     @Override
     59     public boolean isClosed() {
     60         return mDelegate.isClosed();
     61     }
     62 
     63     @Override
     64     public String toString() {
     65         return mDelegate.toString();
     66     }
     67 }
     68