Make getters and setters null-safety consistent

This commit ensure that null-safety is consistent between
getters and setters in order to be able to provide beans
with properties with a common type when type safety is
taken in account like with Kotlin.

It also add a few missing property level @Nullable
annotations.

Issue: SPR-15792
This commit is contained in:
Sebastien Deleuze
2017-07-19 08:55:05 +02:00
parent ff85726fa9
commit fb4ddb0746
201 changed files with 579 additions and 489 deletions

View File

@@ -39,9 +39,11 @@ class HeaderValueHolder {
private final List<Object> values = new LinkedList<>();
public void setValue(Object value) {
public void setValue(@Nullable Object value) {
this.values.clear();
this.values.add(value);
if (value != null) {
this.values.add(value);
}
}
public void addValue(Object value) {

View File

@@ -917,7 +917,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
return this.asyncSupported;
}
public void setAsyncContext(MockAsyncContext asyncContext) {
public void setAsyncContext(@Nullable MockAsyncContext asyncContext) {
this.asyncContext = asyncContext;
}
@@ -941,7 +941,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
// HttpServletRequest interface
// ---------------------------------------------------------------------
public void setAuthType(String authType) {
public void setAuthType(@Nullable String authType) {
this.authType = authType;
}
@@ -1102,7 +1102,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
}
}
public void setMethod(String method) {
public void setMethod(@Nullable String method) {
this.method = method;
}
@@ -1167,7 +1167,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
((MockServletContext) this.servletContext).getDeclaredRoles().contains(role)));
}
public void setUserPrincipal(Principal userPrincipal) {
public void setUserPrincipal(@Nullable Principal userPrincipal) {
this.userPrincipal = userPrincipal;
}
@@ -1177,7 +1177,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
return this.userPrincipal;
}
public void setRequestedSessionId(String requestedSessionId) {
public void setRequestedSessionId(@Nullable String requestedSessionId) {
this.requestedSessionId = requestedSessionId;
}
@@ -1187,7 +1187,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
return this.requestedSessionId;
}
public void setRequestURI(String requestURI) {
public void setRequestURI(@Nullable String requestURI) {
this.requestURI = requestURI;
}

View File

@@ -642,7 +642,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
// Methods for MockRequestDispatcher
//---------------------------------------------------------------------
public void setForwardedUrl(String forwardedUrl) {
public void setForwardedUrl(@Nullable String forwardedUrl) {
this.forwardedUrl = forwardedUrl;
}

View File

@@ -582,7 +582,7 @@ public class MockServletContext implements ServletContext {
}
// @Override - but only against Servlet 4.0
public void setRequestCharacterEncoding(String requestCharacterEncoding) {
public void setRequestCharacterEncoding(@Nullable String requestCharacterEncoding) {
this.requestCharacterEncoding = requestCharacterEncoding;
}
@@ -593,7 +593,7 @@ public class MockServletContext implements ServletContext {
}
// @Override - but only against Servlet 4.0
public void setResponseCharacterEncoding(String responseCharacterEncoding) {
public void setResponseCharacterEncoding(@Nullable String responseCharacterEncoding) {
this.responseCharacterEncoding = responseCharacterEncoding;
}

View File

@@ -76,7 +76,7 @@ class DefaultMvcResult implements MvcResult {
return this.mockResponse;
}
public void setHandler(Object handler) {
public void setHandler(@Nullable Object handler) {
this.handler = handler;
}