1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.commons.collections.buffer;
18
19 import org.apache.commons.collections.Buffer;
20 import org.apache.commons.collections.collection.AbstractCollectionDecorator;
21
22 /**
23 * Decorates another {@link Buffer} to provide additional behaviour.
24 * <p>
25 * Methods are forwarded directly to the decorated buffer.
26 *
27 * @param <E> the type of the elements in the buffer
28 * @since 3.0
29 * @version $Id: AbstractBufferDecorator.java 1429905 2013-01-07 17:15:14Z ggregory $
30 */
31 public abstract class AbstractBufferDecorator<E> extends AbstractCollectionDecorator<E>
32 implements Buffer<E> {
33
34 /** Serialization version */
35 private static final long serialVersionUID = -2629815475789577029L;
36
37 /**
38 * Constructor only used in deserialization, do not use otherwise.
39 * @since 3.1
40 */
41 protected AbstractBufferDecorator() {
42 super();
43 }
44
45 /**
46 * Constructor that wraps (not copies).
47 *
48 * @param buffer the buffer to decorate, must not be null
49 * @throws IllegalArgumentException if list is null
50 */
51 protected AbstractBufferDecorator(final Buffer<E> buffer) {
52 super(buffer);
53 }
54
55 /**
56 * Gets the buffer being decorated.
57 *
58 * @return the decorated buffer
59 */
60 @Override
61 protected Buffer<E> decorated() {
62 return (Buffer<E>) super.decorated();
63 }
64
65 //-----------------------------------------------------------------------
66
67 public E get() {
68 return decorated().get();
69 }
70
71 public E remove() {
72 return decorated().remove();
73 }
74
75 }