Skip to content

Commit 44a5c9f

Browse files
committed
Minor addition to ObjectWriteContext
1 parent 9a70eb2 commit 44a5c9f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main/java/com/fasterxml/jackson/core/ObjectWriteContext.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ public static ObjectWriteContext empty() {
4242
*/
4343
public PrettyPrinter getPrettyPrinter();
4444

45+
/**
46+
* Accessor similar to {@link #getPrettyPrinter()} but which only indicates whether
47+
* a non-{@code null} instance would be constructed if requested, or not.
48+
* This is useful for backends that have custom pretty-printing instead of relying on
49+
* Jackson standard mechanism.
50+
*
51+
* @return True if {@link #getPrettyPrinter()} would return non-{@code null}; false otherwise.
52+
*/
53+
public boolean hasPrettyPrinter();
54+
4555
public SerializableString getRootValueSeparator(SerializableString defaultSeparator);
4656

4757
public int getStreamWriteFeatures(int defaults);
@@ -114,6 +124,11 @@ public static class Base implements ObjectWriteContext {
114124
@Override
115125
public PrettyPrinter getPrettyPrinter() { return null; }
116126

127+
@Override
128+
public boolean hasPrettyPrinter() {
129+
return getPrettyPrinter() != null;
130+
}
131+
117132
@Override
118133
public SerializableString getRootValueSeparator(SerializableString defaultSeparator) {
119134
return defaultSeparator;

0 commit comments

Comments
 (0)