@Test public void shouldPassAccumulatedElementsToTheSuppliedBuilderFunctionAndReturnTheResult() throws Exception { SetBuilder<Integer> setBuilder = setBuilderWith(1, 2, 3); Set<Integer> expected = setWith(1, 2, 3); Set<Integer> actual = setBuilder.build(new UnaryFunction<Iterable<Integer>, Set<Integer>>() { @Override public Set<Integer> call(Iterable<Integer> elements) { return ImmutableSet.copyOf(elements); } }); assertThat(actual instanceof ImmutableSet, is(true)); assertThat(actual, is(expected)); }
@Override public Set<E> build() { return Collections.unmodifiableSet(new HashSet<E>(elements)); }
SetBuilder extends AbstractBuilder<E, SetBuilder<E>, Set<E>> implements AbstractBuilder.WithCustomImplementationSupport<E, Set, Set<E>> { @Override public Set<E> build() { return Collections.unmodifiableSet(new HashSet<E>(elements)); } }
SetBuilder extends AbstractBuilder<E, SetBuilder<E>, Set<E>> implements AbstractBuilder.WithCustomImplementationSupport<E, Set, Set<E>> { @Override public Set<E> build() { return Collections.unmodifiableSet(new HashSet<E>(elements)); }  }
SetBuilder extends AbstractBuilder<E, SetBuilder<E>, Set<E>> implements AbstractBuilder.WithCustomImplementationSupport<E, Set, Set<E>> { @Override public Set<E> build() { return Collections.unmodifiableSet(new HashSet<E>(elements)); }  static SetBuilder<E> setBuilder(); static SetBuilder<E> setBuilder(Class<E> elementClass); @Override Set<E> build(); @Override Set<E> build(Class<? extends Set> implementationClass); @Override T build(UnaryFunction<? super Iterable<E>, ? extends T> builderFunction); }
SetBuilder extends AbstractBuilder<E, SetBuilder<E>, Set<E>> implements AbstractBuilder.WithCustomImplementationSupport<E, Set, Set<E>> { @Override public Set<E> build() { return Collections.unmodifiableSet(new HashSet<E>(elements)); }  static SetBuilder<E> setBuilder(); static SetBuilder<E> setBuilder(Class<E> elementClass); @Override Set<E> build(); @Override Set<E> build(Class<? extends Set> implementationClass); @Override T build(UnaryFunction<? super Iterable<E>, ? extends T> builderFunction);  }