com.google.common.collect.testing
Class OneSizeGenerator<T,E>

java.lang.Object
  extended by com.google.common.collect.testing.OneSizeGenerator<T,E>
All Implemented Interfaces:
OneSizeTestContainerGenerator<T,E>, TestContainerGenerator<T,E>, TestSubjectGenerator<T>

@GwtCompatible
public final class OneSizeGenerator<T,E>
extends Object
implements OneSizeTestContainerGenerator<T,E>

Generator for collection of a particular size.

This class is GWT compatible.

Author:
George van den Driessche

Constructor Summary
OneSizeGenerator(TestContainerGenerator<T,E> generator, CollectionSize collectionSize)
           
 
Method Summary
 T create(Object... elements)
          Creates a new container containing the given elements.
 E[] createArray(int length)
          Helper method to create an array of the appropriate type used by this generator.
 T createTestSubject()
           
 CollectionSize getCollectionSize()
           
 TestContainerGenerator<T,E> getInnerGenerator()
           
 Collection<E> getSampleElements(int howMany)
           
 Iterable<E> order(List<E> insertionOrder)
          Returns the iteration ordering of elements, given the order in which they were added to the container.
 SampleElements<E> samples()
          Returns the sample elements that this generate populates its container with.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OneSizeGenerator

public OneSizeGenerator(TestContainerGenerator<T,E> generator,
                        CollectionSize collectionSize)
Method Detail

getInnerGenerator

public TestContainerGenerator<T,E> getInnerGenerator()
Specified by:
getInnerGenerator in interface OneSizeTestContainerGenerator<T,E>

samples

public SampleElements<E> samples()
Description copied from interface: TestContainerGenerator
Returns the sample elements that this generate populates its container with.

Specified by:
samples in interface TestContainerGenerator<T,E>

create

public T create(Object... elements)
Description copied from interface: TestContainerGenerator
Creates a new container containing the given elements. TODO: would be nice to figure out how to use E... or E[] as a parameter type, but this doesn't seem to work because Java creates an array of the erased type.

Specified by:
create in interface TestContainerGenerator<T,E>

createArray

public E[] createArray(int length)
Description copied from interface: TestContainerGenerator
Helper method to create an array of the appropriate type used by this generator. The returned array will contain only nulls.

Specified by:
createArray in interface TestContainerGenerator<T,E>

createTestSubject

public T createTestSubject()
Specified by:
createTestSubject in interface TestSubjectGenerator<T>

getSampleElements

public Collection<E> getSampleElements(int howMany)
Specified by:
getSampleElements in interface OneSizeTestContainerGenerator<T,E>

getCollectionSize

public CollectionSize getCollectionSize()
Specified by:
getCollectionSize in interface OneSizeTestContainerGenerator<T,E>

order

public Iterable<E> order(List<E> insertionOrder)
Description copied from interface: TestContainerGenerator
Returns the iteration ordering of elements, given the order in which they were added to the container. This method may return the original list unchanged, the original list modified in place, or a different list.

This method runs only when CollectionFeature.KNOWN_ORDER is specified when creating the test suite. It should never run when testing containers such as HashSet, which have a non-deterministic iteration order.

Specified by:
order in interface TestContainerGenerator<T,E>


Copyright © 2010-2012. All Rights Reserved.