Skip to content

Commit

Permalink
Fixed #924
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 6, 2015
1 parent 25fc003 commit 03a3b55
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions release-notes/CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,7 @@ Ievgen Pianov (pyanoveugen@github)
Miles Kaufmann (milesk-amzn@github)
* Reported #432: `StdValueInstantiator` unwraps exceptions, losing context
(2.7.0)

Jirka Kremser (Jiri-Kremser@github)
* Suggested #924: SequenceWriter.writeAll() could accept Iterable
(2.7.0)
2 changes: 2 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Project: jackson-databind
#819: Add support for setting `FormatFeature` via `ObjectReader`, `ObjectWriter`
#918: Add `MapperFeature.ALLOW_EXPLICIT_PROPERTY_RENAMING`
(contributed by David H)
#924: `SequenceWriter.writeAll()` could accept `Iterable`
(suggested by Jiri-Kremser@github(
#932: Rewrite ser/deser for `AtomicReference`, based on "optional" ser/desers
#933: Close some gaps to allow using the `tryToResolveUnresolved` flows
#936: Deserialization into List subtype with JsonCreator no longer works
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/fasterxml/jackson/databind/SequenceWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ public SequenceWriter writeAll(Object[] value) throws IOException
return this;
}

@Deprecated
public <C extends Collection<?>> SequenceWriter writeAll(C container) throws IOException
{
for (Object value : container) {
Expand All @@ -204,6 +205,17 @@ public <C extends Collection<?>> SequenceWriter writeAll(C container) throws IOE
return this;
}

/**
* @since 2.7
*/
public SequenceWriter writeAll(Iterable<?> iterable) throws IOException
{
for (Object value : iterable) {
write(value);
}
return this;
}

@Override
public void flush() throws IOException {
if (!_closed) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.fasterxml.jackson.databind.seq;

import java.io.StringWriter;
import java.util.Arrays;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
Expand Down Expand Up @@ -57,9 +58,11 @@ public void testSimpleNonArray() throws Exception
.writeValues(strw);
w.write(new Bean(13))
.write(new Bean(-6))
.writeAll(new Bean[] { new Bean(3), new Bean(1) });
.writeAll(new Bean[] { new Bean(3), new Bean(1) })
.writeAll(Arrays.asList(new Bean(5), new Bean(7)))
;
w.close();
assertEquals(aposToQuotes("{'a':13}\n{'a':-6}\n{'a':3}\n{'a':1}"),
assertEquals(aposToQuotes("{'a':13}\n{'a':-6}\n{'a':3}\n{'a':1}\n{'a':5}\n{'a':7}"),
strw.toString());
}

Expand Down

0 comments on commit 03a3b55

Please sign in to comment.