All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.undertow.util.AttachmentList Maven / Gradle / Ivy

/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2014 Red Hat, Inc., and individual contributors
 * as indicated by the @author tags.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package io.undertow.util;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.RandomAccess;

/**
 * @author David M. Lloyd
 */
public final class AttachmentList implements List, RandomAccess {

    private final Class valueClass;
    private final List delegate;

    public AttachmentList(final int initialCapacity, final Class valueClass) {
        delegate = Collections.checkedList(new ArrayList(initialCapacity), valueClass);
        this.valueClass = valueClass;
    }

    public AttachmentList(final Class valueClass) {
        delegate = Collections.checkedList(new ArrayList(), valueClass);
        this.valueClass = valueClass;
    }

    public AttachmentList(final Collection c, final Class valueClass) {
        delegate = Collections.checkedList(new ArrayList(c.size()), valueClass);
        delegate.addAll(c);
        this.valueClass = valueClass;
    }

    public Class getValueClass() {
        return valueClass;
    }

    public int size() {
        return delegate.size();
    }

    public boolean isEmpty() {
        return delegate.isEmpty();
    }

    public boolean contains(final Object o) {
        return delegate.contains(o);
    }

    public Iterator iterator() {
        return delegate.iterator();
    }

    public Object[] toArray() {
        return delegate.toArray();
    }

    public  T[] toArray(final T[] a) {
        return delegate.toArray(a);
    }

    public boolean add(final T t) {
        return delegate.add(t);
    }

    public boolean remove(final Object o) {
        return delegate.remove(o);
    }

    public boolean containsAll(final Collection c) {
        return delegate.containsAll(c);
    }

    public boolean addAll(final Collection c) {
        return delegate.addAll(c);
    }

    public boolean addAll(final int index, final Collection c) {
        return delegate.addAll(index, c);
    }

    public boolean removeAll(final Collection c) {
        return delegate.removeAll(c);
    }

    public boolean retainAll(final Collection c) {
        return delegate.retainAll(c);
    }

    public void clear() {
        delegate.clear();
    }

    public boolean equals(final Object o) {
        return delegate.equals(o);
    }

    public int hashCode() {
        return delegate.hashCode();
    }

    public T get(final int index) {
        return delegate.get(index);
    }

    public T set(final int index, final T element) {
        return delegate.set(index, element);
    }

    public void add(final int index, final T element) {
        delegate.add(index, element);
    }

    public T remove(final int index) {
        return delegate.remove(index);
    }

    public int indexOf(final Object o) {
        return delegate.indexOf(o);
    }

    public int lastIndexOf(final Object o) {
        return delegate.lastIndexOf(o);
    }

    public ListIterator listIterator() {
        return delegate.listIterator();
    }

    public ListIterator listIterator(final int index) {
        return delegate.listIterator(index);
    }

    public List subList(final int fromIndex, final int toIndex) {
        return delegate.subList(fromIndex, toIndex);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy