Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nullability annotations to LazyHeaders.Builder functions #3446

Merged
merged 1 commit into from
Dec 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, @NonNull 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