Skip to content

Commit 3b62d78

Browse files
protobuf-github-botgoogleberg
authored andcommitted
Re-export includingDefaultValueFields in deprecated state for important Cloud customer.
PiperOrigin-RevId: 684555053
1 parent 3ea568a commit 3b62d78

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

java/util/src/main/java/com/google/protobuf/util/JsonFormat.java

+29
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,35 @@ public Printer usingTypeRegistry(com.google.protobuf.TypeRegistry registry) {
178178
sortingMapKeys);
179179
}
180180

181+
/**
182+
* Creates a new {@link Printer} that will always print fields unless they are a message type or
183+
* in a oneof.
184+
*
185+
* <p>Note that this does print Proto2 Optional but does not print Proto3 Optional fields, as
186+
* the latter is represented using a synthetic oneof.
187+
*
188+
* <p>The new Printer clones all other configurations from the current {@link Printer}.
189+
*
190+
* @deprecated This method is deprecated, and slated for removal in the next Java breaking
191+
* change (5.x). Prefer {@link #alwaysPrintFieldsWithNoPresence}
192+
*/
193+
@Deprecated
194+
public Printer includingDefaultValueFields() {
195+
if (shouldPrintDefaults != ShouldPrintDefaults.ONLY_IF_PRESENT) {
196+
throw new IllegalStateException(
197+
"JsonFormat includingDefaultValueFields has already been set.");
198+
}
199+
return new Printer(
200+
registry,
201+
oldRegistry,
202+
ShouldPrintDefaults.ALWAYS_PRINT_EXCEPT_MESSAGES_AND_ONEOFS,
203+
ImmutableSet.of(),
204+
preservingProtoFieldNames,
205+
omittingInsignificantWhitespace,
206+
printingEnumsAsInts,
207+
sortingMapKeys);
208+
}
209+
181210
/**
182211
* Creates a new {@link Printer} that will also print default-valued fields if their
183212
* FieldDescriptors are found in the supplied set. Empty repeated fields and map fields will be

0 commit comments

Comments
 (0)