SetFactory implements Factory<Set<T>> { public static <T> Factory<Set<T>> create(Provider<Set<T>> first, @SuppressWarnings("unchecked") Provider<Set<T>>... rest) { if (first == null) { throw new NullPointerException(); } if (rest == null) { throw new NullPointerException(); } Set<Provider<Set<T>>> contributingProviders = newLinkedHashSetWithExpectedSize(1 + rest.length); contributingProviders.add(first); for (Provider<Set<T>> provider : rest) { if (provider == null) { throw new NullPointerException(); } contributingProviders.add(provider); } return new SetFactory<T>(contributingProviders); } private  SetFactory(Set<Provider<Set<T>>> contributingProviders); static Factory<Set<T>> create(Provider<Set<T>> first,
      @SuppressWarnings("unchecked") Provider<Set<T>>... rest); @Override Set<T> get();  }
@Test public void nullFirstProvider() { thrown.expect(NullPointerException.class); SetFactory.create(null); }
@Test public void nullRest() { thrown.expect(NullPointerException.class); SetFactory.create(incrementingIntegerProvider(1), (Provider<Set<Integer>>[]) null); }
@Test public void nullProviderInRest() { thrown.expect(NullPointerException.class); SetFactory.create( incrementingIntegerProvider(1), incrementingIntegerProvider(2), null, incrementingIntegerProvider(3)); }