Skip to content

Commit

Permalink
Add nullability annotations to LazyHeaders.Builder functions
Browse files Browse the repository at this point in the history
  • Loading branch information
r-ralph committed Dec 7, 2018
1 parent f7d8604 commit d47358d
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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));
}

Expand All @@ -146,7 +147,7 @@ public Builder addHeader(String key, String value) {
* <p> This class does not prevent you from adding the same value to a given key multiple
* times </p>
*/
public Builder addHeader(String key, LazyHeaderFactory factory) {
public Builder addHeader(@NonNull String key, @Nullable LazyHeaderFactory factory) {
if (isUserAgentDefault && USER_AGENT_HEADER.equalsIgnoreCase(key)) {
return setHeader(key, factory);
}
Expand All @@ -166,7 +167,7 @@ public Builder addHeader(String key, LazyHeaderFactory factory) {
* (i.e. an OAuth token). </p>
*/
@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));
}

Expand All @@ -176,7 +177,7 @@ public Builder setHeader(String key, String value) {
*
* <p> If the given value is {@code null}, the header at the given key will be removed. </p>
*/
public Builder setHeader(String key, LazyHeaderFactory factory) {
public Builder setHeader(@NonNull String key, @Nullable LazyHeaderFactory factory) {
copyIfNecessary();
if (factory == null) {
headers.remove(key);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit d47358d

Please sign in to comment.