Skip to content

Commit

Permalink
Minor addition to ObjectWriteContext
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 18, 2021
1 parent 9a70eb2 commit 44a5c9f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/com/fasterxml/jackson/core/ObjectWriteContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 44a5c9f

Please sign in to comment.