@Test public void shouldAllowConcreteTypeOfSetToBeReturnedWhenBuildingUsingBuilderFunction() throws Exception { SetBuilder<Integer> setBuilder = setBuilderWith(1, 2, 3) .and(4, 5, 6); TreeSet<Integer> expectedTreeSet = new TreeSet<Integer>(); expectedTreeSet.addAll(listWith(1, 2, 3, 4, 5, 6)); TreeSet<Integer> actualTreeSet = setBuilder.build(new UnaryFunction<Iterable<Integer>, TreeSet<Integer>>() { @Override public TreeSet<Integer> call(Iterable<Integer> elements) { TreeSet<Integer> set = new TreeSet<Integer>(); for (Integer element : elements) { set.add(element); } return set; } }); assertThat(actualTreeSet, is(expectedTreeSet)); }
@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);  }