Skip to content

Commit 61efabc

Browse files
committed
Merge #447 from branch 'metafacture-documentation-19-deprecatePrettyPrintingInEncodeYaml' of github.com:metafacture/metafacture-core
2 parents 2cb7aff + 5bfa115 commit 61efabc

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

metafacture-yaml/src/main/java/org/metafacture/yaml/YamlEncoder.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.fasterxml.jackson.core.SerializableString;
3131
import com.fasterxml.jackson.core.io.CharacterEscapes;
3232
import com.fasterxml.jackson.core.io.SerializedString;
33-
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
3433
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
3534
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
3635

@@ -47,7 +46,7 @@
4746
* @author Jens Wille
4847
*
4948
*/
50-
@Description("Serialises an object as YAML")
49+
@Description("Serialises an object as YAML. The paramter 'prettyprinting (boolean)' is deprecated since it's not possible to not pretty print.")
5150
@In(StreamReceiver.class)
5251
@Out(String.class)
5352
@FluxCommand("encode-yaml")
@@ -95,20 +94,27 @@ public String getArrayMarker() {
9594

9695
/**
9796
* Flags whether the data should be pretty printed.
97+
* @deprecated
98+
* Jackson's YAMLGenerator ignores any PrettyPrinter. It's always
99+
* pretty printed.
98100
*
99101
* @param prettyPrinting true if the data should be pretty printed
100102
*/
103+
@Deprecated
101104
public void setPrettyPrinting(final boolean prettyPrinting) {
102-
yamlGenerator.setPrettyPrinter(prettyPrinting ? new DefaultPrettyPrinter((SerializableString) null) : null);
103105
}
104106

105107
/**
106108
* Checks whether to pretty print.
109+
* @deprecated
110+
* Jackson's YAMLGenerator ignores any PrettyPrinter. It's always
111+
* pretty printed.
107112
*
108113
* @return true if the data should be pretty printed
109114
*/
115+
@Deprecated
110116
public boolean getPrettyPrinting() {
111-
return yamlGenerator.getPrettyPrinter() != null;
117+
return true;
112118
}
113119

114120
/**

metafacture-yaml/src/test/java/org/metafacture/yaml/YamlEncoderTest.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -273,27 +273,6 @@ public void testShouldPrefixOutputWithNewline() {
273273
);
274274
}
275275

276-
@Test
277-
public void testShouldPrefixPrettyPrintedOutputWithNewline() {
278-
assertEncode(
279-
i -> {
280-
i.setPrettyPrinting(true);
281-
282-
i.startRecord("");
283-
i.literal(LITERAL1, VALUE1);
284-
i.endRecord();
285-
i.startRecord("");
286-
i.literal(LITERAL2, VALUE2);
287-
i.endRecord();
288-
},
289-
"---\n" +
290-
"L1: 'V1'",
291-
"\n" +
292-
"---\n" +
293-
"L2: 'V2'"
294-
);
295-
}
296-
297276
private void assertEncode(final Consumer<YamlEncoder> in, final String... out) {
298277
final InOrder ordered = Mockito.inOrder(receiver);
299278

0 commit comments

Comments
 (0)