Java Code Examples for com.google.common.collect.ForwardingList

The following are top voted examples for showing how to use com.google.common.collect.ForwardingList. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: miniguava   File: IteratorsTest.java   View source code 6 votes vote down vote up
@MiniGuavaSpecific // miniguava: Originally testsForRemoveAllAndRetainAll
private static Test testsForRemoveAll() {
  return ListTestSuiteBuilder.using(new TestStringListGenerator() {
    @Override public List<String> create(final String[] elements) {
      final List<String> delegate = newArrayList(elements);
      return new ForwardingList<String>() {
        @Override protected List<String> delegate() {
          return delegate;
        }

        @Override public boolean removeAll(Collection<?> c) {
          return Iterators.removeAll(iterator(), c);
        }
      };
    }
  })
    .named("ArrayList with Iterators.removeAll")
    .withFeatures(
      ListFeature.GENERAL_PURPOSE,
      CollectionFeature.ALLOWS_NULL_VALUES,
      CollectionSize.ANY)
    .createTestSuite();
}
 
Example 2
Project: uzaygezen   File: LinkedNodeList.java   View source code 5 votes vote down vote up
@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 protected List<E> delegate() {
      return delegate;
    }
  };
}