Document the reason for defining private method defaultIfNull

PiperOrigin-RevId: 495004732
(cherry picked from commit c3ca71fda738772dccc5a5e07293c884d2194f0a)
This commit is contained in:
rohks 2022-12-13 14:27:54 +00:00 committed by christosts
parent 47b811e3b9
commit aa2158d5c8

View File

@ -1668,6 +1668,14 @@ public final class Format implements Bundleable {
+ Integer.toString(initialisationDataIndex, Character.MAX_RADIX);
}
/**
* Utility method to get {@code defaultValue} if {@code value} is {@code null}. {@code
* defaultValue} can be {@code null}.
*
* <p>Note: Current implementations of getters in {@link Bundle}, for example {@link
* Bundle#getString(String, String)} does not allow the defaultValue to be {@code null}, hence the
* need for this method.
*/
@Nullable
private static <T> T defaultIfNull(@Nullable T value, @Nullable T defaultValue) {
return value != null ? value : defaultValue;