Skip to content

Commit

Permalink
Deprecate parameter "prettyPrinting"
Browse files Browse the repository at this point in the history
Jackson's YAMLGenerator ignores any PrettyPrinter. It's always
pretty printed.

- mark methods as deprecated
- note deprecation in description
- update test

See metafacture/metafacture-documentation#19.
  • Loading branch information
dr0i committed Jun 2, 2022
1 parent 2cb7aff commit 600aa2a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Expand Up @@ -30,7 +30,6 @@
import com.fasterxml.jackson.core.SerializableString;
import com.fasterxml.jackson.core.io.CharacterEscapes;
import com.fasterxml.jackson.core.io.SerializedString;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;

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

/**
* Flags whether the data should be pretty printed.
* @deprecated
* Jackson's YAMLGenerator ignores any PrettyPrinter. It's always
* pretty printed.
*
* @param prettyPrinting true if the data should be pretty printed
*/
@Deprecated
public void setPrettyPrinting(final boolean prettyPrinting) {
yamlGenerator.setPrettyPrinter(prettyPrinting ? new DefaultPrettyPrinter((SerializableString) null) : null);
}

/**
* Checks whether to pretty print.
* @deprecated
* Jackson's YAMLGenerator ignores any PrettyPrinter. It's always
* pretty printed.
*
* @return true if the data should be pretty printed
*/
@Deprecated
public boolean getPrettyPrinting() {
return yamlGenerator.getPrettyPrinter() != null;
return true;
}

/**
Expand Down
Expand Up @@ -277,8 +277,6 @@ public void testShouldPrefixOutputWithNewline() {
public void testShouldPrefixPrettyPrintedOutputWithNewline() {
assertEncode(
i -> {
i.setPrettyPrinting(true);

i.startRecord("");
i.literal(LITERAL1, VALUE1);
i.endRecord();
Expand Down

0 comments on commit 600aa2a

Please sign in to comment.