diff --git a/src/main/java/com/fasterxml/jackson/core/ObjectWriteContext.java b/src/main/java/com/fasterxml/jackson/core/ObjectWriteContext.java index b9fe24fd27..e1b44a7236 100644 --- a/src/main/java/com/fasterxml/jackson/core/ObjectWriteContext.java +++ b/src/main/java/com/fasterxml/jackson/core/ObjectWriteContext.java @@ -42,6 +42,16 @@ public static ObjectWriteContext empty() { */ public PrettyPrinter getPrettyPrinter(); + /** + * Accessor similar to {@link #getPrettyPrinter()} but which only indicates whether + * a non-{@code null} instance would be constructed if requested, or not. + * This is useful for backends that have custom pretty-printing instead of relying on + * Jackson standard mechanism. + * + * @return True if {@link #getPrettyPrinter()} would return non-{@code null}; false otherwise. + */ + public boolean hasPrettyPrinter(); + public SerializableString getRootValueSeparator(SerializableString defaultSeparator); public int getStreamWriteFeatures(int defaults); @@ -114,6 +124,11 @@ public static class Base implements ObjectWriteContext { @Override public PrettyPrinter getPrettyPrinter() { return null; } + @Override + public boolean hasPrettyPrinter() { + return getPrettyPrinter() != null; + } + @Override public SerializableString getRootValueSeparator(SerializableString defaultSeparator) { return defaultSeparator;