From 22c3de05e1018b87c4b1595e75734e4716a20034 Mon Sep 17 00:00:00 2001 From: Ralph Date: Fri, 7 Dec 2018 14:26:40 +0900 Subject: [PATCH] Add nullability annotations to LazyHeaders.Builder functions --- .../com/bumptech/glide/load/model/LazyHeaders.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/library/src/main/java/com/bumptech/glide/load/model/LazyHeaders.java b/library/src/main/java/com/bumptech/glide/load/model/LazyHeaders.java index e7f446ca56..3a03d37b11 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/LazyHeaders.java +++ b/library/src/main/java/com/bumptech/glide/load/model/LazyHeaders.java @@ -1,6 +1,7 @@ package com.bumptech.glide.load.model; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.text.TextUtils; import java.util.ArrayList; @@ -132,7 +133,7 @@ public static final class Builder { * * @see #addHeader(String, LazyHeaderFactory) */ - public Builder addHeader(String key, String value) { + public Builder addHeader(@NonNull String key, @NonNull String value) { return addHeader(key, new StringHeaderFactory(value)); } @@ -146,7 +147,7 @@ public Builder addHeader(String key, String value) { *

This class does not prevent you from adding the same value to a given key multiple * times

*/ - public Builder addHeader(String key, LazyHeaderFactory factory) { + public Builder addHeader(@NonNull String key, @NonNull LazyHeaderFactory factory) { if (isUserAgentDefault && USER_AGENT_HEADER.equalsIgnoreCase(key)) { return setHeader(key, factory); } @@ -166,7 +167,7 @@ public Builder addHeader(String key, LazyHeaderFactory factory) { * (i.e. an OAuth token).

*/ @SuppressWarnings({"UnusedReturnValue", "WeakerAccess"}) // Public API - public Builder setHeader(String key, String value) { + public Builder setHeader(@NonNull String key, @Nullable String value) { return setHeader(key, value == null ? null : new StringHeaderFactory(value)); } @@ -176,7 +177,7 @@ public Builder setHeader(String key, String value) { * *

If the given value is {@code null}, the header at the given key will be removed.

*/ - public Builder setHeader(String key, LazyHeaderFactory factory) { + public Builder setHeader(@NonNull String key, @Nullable LazyHeaderFactory factory) { copyIfNecessary(); if (factory == null) { headers.remove(key); @@ -255,9 +256,10 @@ static String getSanitizedUserAgent() { static final class StringHeaderFactory implements LazyHeaderFactory { + @NonNull private final String value; - StringHeaderFactory(String value) { + StringHeaderFactory(@NonNull String value) { this.value = value; }