Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nings.

RELNOTES=n/a
PiperOrigin-RevId: 726172349
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Feb 12, 2025
1 parent b6c232c commit d0c23aa
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
6 changes: 5 additions & 1 deletion android/guava/src/com/google/common/base/Optional.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ public static <T> Optional<T> fromNullable(@Nullable T nullableReference) {
*
* @since 33.4.0 (but since 21.0 in the JRE flavor)
*/
@SuppressWarnings("Java7ApiChecker")
@SuppressWarnings({
"NullableOptional", // Null passthrough is reasonable for type conversions
"Java7ApiChecker",
})
@IgnoreJRERequirement // Users will use this only if they're already using Optional.
public static <T> @Nullable Optional<T> fromJavaUtil(
java.util.@Nullable Optional<T> javaUtilOptional) {
Expand All @@ -149,6 +152,7 @@ public static <T> Optional<T> fromNullable(@Nullable T nullableReference) {
*/
@SuppressWarnings({
"AmbiguousMethodReference", // We chose the name despite knowing this risk.
"NullableOptional", // Null passthrough is reasonable for type conversions
"Java7ApiChecker",
})
// If users use this when they shouldn't, we hope that NewApi will catch subsequent Optional calls
Expand Down
5 changes: 4 additions & 1 deletion android/guava/src/com/google/common/net/MediaType.java
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,10 @@ private static MediaType addKnownType(MediaType mediaType) {

@LazyInit private int hashCode;

@LazyInit private @Nullable Optional<Charset> parsedCharset;
// We need to differentiate between "not computed" and "computed to be absent."
@SuppressWarnings("NullableOptional")
@LazyInit
private @Nullable Optional<Charset> parsedCharset;

private MediaType(String type, String subtype, ImmutableListMultimap<String, String> parameters) {
this.type = type;
Expand Down
6 changes: 5 additions & 1 deletion guava/src/com/google/common/base/Optional.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public static <T> Optional<T> fromNullable(@Nullable T nullableReference) {
*
* @since 21.0 (but only since 33.4.0 in the Android flavor)
*/
@SuppressWarnings("NullableOptional") // Null passthrough is reasonable for type conversions
public static <T> @Nullable Optional<T> fromJavaUtil(
java.util.@Nullable Optional<T> javaUtilOptional) {
return (javaUtilOptional == null) ? null : fromNullable(javaUtilOptional.orElse(null));
Expand All @@ -145,7 +146,10 @@ public static <T> Optional<T> fromNullable(@Nullable T nullableReference) {
*
* @since 21.0 (but only since 33.4.0 in the Android flavor)
*/
@SuppressWarnings("AmbiguousMethodReference") // We chose the name despite knowing this risk.
@SuppressWarnings({
"AmbiguousMethodReference", // We chose the name despite knowing this risk.
"NullableOptional", // Null passthrough is reasonable for type conversions
})
public static <T> java.util.@Nullable Optional<T> toJavaUtil(
@Nullable Optional<T> googleOptional) {
return googleOptional == null ? null : googleOptional.toJavaUtil();
Expand Down
5 changes: 4 additions & 1 deletion guava/src/com/google/common/net/MediaType.java
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,10 @@ private static MediaType addKnownType(MediaType mediaType) {

@LazyInit private int hashCode;

@LazyInit private @Nullable Optional<Charset> parsedCharset;
// We need to differentiate between "not computed" and "computed to be absent."
@SuppressWarnings("NullableOptional")
@LazyInit
private @Nullable Optional<Charset> parsedCharset;

private MediaType(String type, String subtype, ImmutableListMultimap<String, String> parameters) {
this.type = type;
Expand Down

0 comments on commit d0c23aa

Please sign in to comment.