Resolve remaining nullability warnings
Issue: SPR-15869
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.web.reactive.result.condition;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
/**
|
||||
@@ -36,20 +37,22 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
|
||||
|
||||
protected final boolean isNegated;
|
||||
|
||||
|
||||
AbstractNameValueExpression(String expression) {
|
||||
int separator = expression.indexOf('=');
|
||||
if (separator == -1) {
|
||||
this.isNegated = expression.startsWith("!");
|
||||
this.name = isNegated ? expression.substring(1) : expression;
|
||||
this.name = (this.isNegated ? expression.substring(1) : expression);
|
||||
this.value = null;
|
||||
}
|
||||
else {
|
||||
this.isNegated = (separator > 0) && (expression.charAt(separator - 1) == '!');
|
||||
this.name = isNegated ? expression.substring(0, separator - 1) : expression.substring(0, separator);
|
||||
this.name = (this.isNegated ? expression.substring(0, separator - 1) : expression.substring(0, separator));
|
||||
this.value = parseValue(expression.substring(separator + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
@@ -66,10 +69,6 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
|
||||
return this.isNegated;
|
||||
}
|
||||
|
||||
protected abstract boolean isCaseSensitiveName();
|
||||
|
||||
protected abstract T parseValue(String valueExpression);
|
||||
|
||||
public final boolean match(ServerWebExchange exchange) {
|
||||
boolean isMatch;
|
||||
if (this.value != null) {
|
||||
@@ -81,10 +80,16 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
|
||||
return this.isNegated != isMatch;
|
||||
}
|
||||
|
||||
|
||||
protected abstract boolean isCaseSensitiveName();
|
||||
|
||||
protected abstract T parseValue(String valueExpression);
|
||||
|
||||
protected abstract boolean matchName(ServerWebExchange exchange);
|
||||
|
||||
protected abstract boolean matchValue(ServerWebExchange exchange);
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
@@ -103,28 +108,28 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = isCaseSensitiveName() ? name.hashCode() : name.toLowerCase().hashCode();
|
||||
result = 31 * result + (value != null ? value.hashCode() : 0);
|
||||
result = 31 * result + (isNegated ? 1 : 0);
|
||||
int result = (isCaseSensitiveName() ? this.name : this.name.toLowerCase()).hashCode();
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(this.value);
|
||||
result = 31 * result + (this.isNegated ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if (value != null) {
|
||||
builder.append(name);
|
||||
if (isNegated) {
|
||||
if (this.value != null) {
|
||||
builder.append(this.name);
|
||||
if (this.isNegated) {
|
||||
builder.append('!');
|
||||
}
|
||||
builder.append('=');
|
||||
builder.append(value);
|
||||
builder.append(this.value);
|
||||
}
|
||||
else {
|
||||
if (isNegated) {
|
||||
if (this.isNegated) {
|
||||
builder.append('!');
|
||||
}
|
||||
builder.append(name);
|
||||
builder.append(this.name);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -159,12 +159,12 @@ public final class HeadersRequestCondition extends AbstractRequestCondition<Head
|
||||
|
||||
@Override
|
||||
protected boolean matchName(ServerWebExchange exchange) {
|
||||
return exchange.getRequest().getHeaders().get(name) != null;
|
||||
return (exchange.getRequest().getHeaders().get(this.name) != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matchValue(ServerWebExchange exchange) {
|
||||
return value.equals(exchange.getRequest().getHeaders().getFirst(name));
|
||||
return (this.value != null && this.value.equals(exchange.getRequest().getHeaders().getFirst(this.name)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -146,7 +146,8 @@ public final class ParamsRequestCondition extends AbstractRequestCondition<Param
|
||||
|
||||
@Override
|
||||
protected boolean matchValue(ServerWebExchange exchange) {
|
||||
return this.value.equals(exchange.getRequest().getQueryParams().getFirst(this.name));
|
||||
return (this.value != null &&
|
||||
this.value.equals(exchange.getRequest().getQueryParams().getFirst(this.name)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ class DefaultRendering implements Rendering {
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object view() {
|
||||
return this.view;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public interface Rendering {
|
||||
/**
|
||||
* Return the selected {@link String} view name or {@link View} object.
|
||||
*/
|
||||
@Nullable
|
||||
Object view();
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user