@Test public void shouldPassAccumulatedElementsToTheSuppliedBuilderFunctionAndReturnTheResult() throws Exception { ListBuilder<Integer> listBuilder = listBuilderWith(1, 2, 3); List<Integer> expected = listWith(1, 2, 3); List<Integer> actual = listBuilder.build(new UnaryFunction<Iterable<Integer>, List<Integer>>() { @Override public List<Integer> call(Iterable<Integer> elements) { return ImmutableList.copyOf(elements); } }); assertThat(actual instanceof ImmutableList, is(true)); assertThat(actual, is(expected)); }
@Override public List<E> build() { return Collections.unmodifiableList(new ArrayList<E>(elements)); }
ListBuilder extends AbstractBuilder<E, ListBuilder<E>, List<E>> implements AbstractBuilder.WithCustomImplementationSupport<E, List, List<E>> { @Override public List<E> build() { return Collections.unmodifiableList(new ArrayList<E>(elements)); } }
ListBuilder extends AbstractBuilder<E, ListBuilder<E>, List<E>> implements AbstractBuilder.WithCustomImplementationSupport<E, List, List<E>> { @Override public List<E> build() { return Collections.unmodifiableList(new ArrayList<E>(elements)); }  }
ListBuilder extends AbstractBuilder<E, ListBuilder<E>, List<E>> implements AbstractBuilder.WithCustomImplementationSupport<E, List, List<E>> { @Override public List<E> build() { return Collections.unmodifiableList(new ArrayList<E>(elements)); }  static ListBuilder<E> listBuilder(); static ListBuilder<E> listBuilder(Class<E> elementClass); @Override List<E> build(); @Override List<E> build(Class<? extends List> implementationClass); @Override T build(UnaryFunction<? super Iterable<E>, ? extends T> builderFunction); }
ListBuilder extends AbstractBuilder<E, ListBuilder<E>, List<E>> implements AbstractBuilder.WithCustomImplementationSupport<E, List, List<E>> { @Override public List<E> build() { return Collections.unmodifiableList(new ArrayList<E>(elements)); }  static ListBuilder<E> listBuilder(); static ListBuilder<E> listBuilder(Class<E> elementClass); @Override List<E> build(); @Override List<E> build(Class<? extends List> implementationClass); @Override T build(UnaryFunction<? super Iterable<E>, ? extends T> builderFunction);  }