ImmutableJsonObjectBuilder implements JsonObjectBuilder { @Override public ImmutableJsonObjectBuilder setAll(final Iterable<JsonField> fields, final Predicate<JsonField> predicate) { requireNonNull(fields, "The JSON fields to be set must not be null!"); checkPredicate(predicate); StreamSupport.stream(fields.spliterator(), false) .filter(field -> !field.getDefinition().isPresent() || predicate.test(field)) .forEach(fieldToBeSet -> this.fields.put(fieldToBeSet.getKeyName(), fieldToBeSet)); return this; } private  ImmutableJsonObjectBuilder(); static ImmutableJsonObjectBuilder newInstance(); @Override ImmutableJsonObjectBuilder set(final CharSequence key, final int value,
            final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder set(final CharSequence key, final long value,
            final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder set(final CharSequence key, final double value,
            final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder set(final CharSequence key, final boolean value,
            final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder set(final CharSequence key, @Nullable final String value,
            final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder set(final CharSequence key, final JsonValue value,
            final Predicate<JsonField> predicate); @Override JsonObjectBuilder set(final JsonFieldDefinition<T> fieldDefinition, @Nullable final T value,
            final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder set(final JsonField field, final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder remove(final CharSequence key); @Override ImmutableJsonObjectBuilder remove(final JsonFieldDefinition fieldDefinition); @Override ImmutableJsonObjectBuilder setAll(final Iterable<JsonField> fields, final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder setAll(final Iterable<JsonField> fields); @Override ImmutableJsonObjectBuilder removeAll(); @Override Iterator<JsonField> iterator(); @Override boolean isEmpty(); @Override int getSize(); @Override Stream<JsonField> stream(); @Override JsonObject build(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void tryToInvokeSetAllWithNullIterator() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> underTest.setAll(null)) .withMessage("The %s must not be null!", "JSON fields to be set") .withNoCause(); }
@Test public void setAllSetsAllSpecifiedFieldsWithoutDuplicates() { final Collection<JsonField> fieldsToBeSet = new ArrayList<>(); Collections.addAll(fieldsToBeSet, eddard, cersei, robert, john, cersei, hodor, hodor); underTest.setAll(fieldsToBeSet); assertThat(underTest).containsExactly(eddard, cersei, robert, john, hodor); }