@Test public void shouldAddElementsToACollectionOfTheSpecifiedImplementationInTheOrderTheyWereAddedToTheBuilder() throws Exception { Collection<Integer> expected = new ArrayList<Integer>(listWith(8, 7, 6, 5, 4)); CollectionBuilder<Integer> collectionBuilder = collectionBuilderWith(8, 7) .and(6, 5) .and(4); Collection<Integer> actual = collectionBuilder.build(ArrayList.class); List<Integer> expectedElements = listFrom(expected); List<Integer> actualElements = listFrom(actual); assertThat(actualElements, hasOnlyItemsInOrder(expectedElements)); }
@Override public Collection<E> build() { return Collections.unmodifiableList(new ArrayList<E>(elements)); }
CollectionBuilder extends AbstractBuilder<E, CollectionBuilder<E>, Collection<E>> implements AbstractBuilder.WithCustomImplementationSupport<E, Collection, Collection<E>> { @Override public Collection<E> build() { return Collections.unmodifiableList(new ArrayList<E>(elements)); } }
CollectionBuilder extends AbstractBuilder<E, CollectionBuilder<E>, Collection<E>> implements AbstractBuilder.WithCustomImplementationSupport<E, Collection, Collection<E>> { @Override public Collection<E> build() { return Collections.unmodifiableList(new ArrayList<E>(elements)); }  }
CollectionBuilder extends AbstractBuilder<E, CollectionBuilder<E>, Collection<E>> implements AbstractBuilder.WithCustomImplementationSupport<E, Collection, Collection<E>> { @Override public Collection<E> build() { return Collections.unmodifiableList(new ArrayList<E>(elements)); }  static CollectionBuilder<E> collectionBuilder(); static CollectionBuilder<E> collectionBuilder(Class<E> elementClass); @Override Collection<E> build(); @Override Collection<E> build(Class<? extends Collection> implementationClass); @Override T build(UnaryFunction<? super Iterable<E>, ? extends T> builderFunction); }
CollectionBuilder extends AbstractBuilder<E, CollectionBuilder<E>, Collection<E>> implements AbstractBuilder.WithCustomImplementationSupport<E, Collection, Collection<E>> { @Override public Collection<E> build() { return Collections.unmodifiableList(new ArrayList<E>(elements)); }  static CollectionBuilder<E> collectionBuilder(); static CollectionBuilder<E> collectionBuilder(Class<E> elementClass); @Override Collection<E> build(); @Override Collection<E> build(Class<? extends Collection> implementationClass); @Override T build(UnaryFunction<? super Iterable<E>, ? extends T> builderFunction);  }