Example usage for com.google.common.collect ForwardingList ForwardingList

List of usage examples for com.google.common.collect ForwardingList ForwardingList

Introduction

In this page you can find the example usage for com.google.common.collect ForwardingList ForwardingList.

Prototype

protected ForwardingList() 

Source Link

Document

Constructor for use by subclasses.

Usage

From source file:com.google.uzaygezen.core.LinkedNodeList.java

@Override
public List<E> subList(int fromIndex, int toIndex) {
    // Using ForwardingList so removeAll(null) and retainAll(null) throw a NPE
    final List<E> delegate = super.subList(fromIndex, toIndex);
    return new ForwardingList<E>() {
        @Override//from   w ww  .  j  a v  a  2  s.co m
        protected List<E> delegate() {
            return delegate;
        }
    };
}

From source file:org.iternine.jeppetto.dao.mongodb.enhance.DBObjectUtil.java

private static List<Object> wrapList(final Type valueType, final Iterable<Object> delegate) {
    final List<Object> delegateList = Lists.newArrayList(delegate);

    return new ForwardingList<Object>() {
        @Override//from   w ww.j  a v a  2s. com
        protected List<Object> delegate() {
            return delegateList;
        }

        @Override
        public Object get(int index) {
            return toDBObject((Class<?>) valueType, super.get(index));
        }

        @Override
        public Iterator<Object> iterator() {
            final Iterator<Object> delegateIterator = delegateList.iterator();

            return new Iterator<Object>() {
                @Override
                public boolean hasNext() {
                    return delegateIterator.hasNext();
                }

                @Override
                public Object next() {
                    return toDBObject((Class<?>) valueType, delegateIterator.next());
                }

                @Override
                public void remove() {
                    delegateIterator.remove();
                }
            };
        }
    };
}

From source file:com.tinspx.util.net.Headers.java

/**
 * Returns all values mapped to the specified header {@code name}. The
 * returned list is a "live" view of the headers mapped to {@code name}, so
 * any values added or removed with the given header {@code name} will be
 * reflected in the returned list. However, the returned list is <i>not</i>
 * modifiable./*  www  .ja  va2s.c o m*/
 */
public List<String> get(@Nullable String name) {
    if (name == null) {
        return Collections.emptyList();
    }
    final List<String> delegate = canonHeaders().get(canonicalize(name));
    return Collections.unmodifiableList(new ForwardingList<String>() {
        @Override
        protected List<String> delegate() {
            if (rebuildHeaders) {
                canonHeaders();
            }
            return delegate;
        }
    });
}