Use enhanced switch expressions where feasible
Closes gh-28014
This commit is contained in:
@@ -154,18 +154,10 @@ final class Jackson2Tokenizer {
|
||||
|
||||
private void updateDepth(JsonToken token) {
|
||||
switch (token) {
|
||||
case START_OBJECT:
|
||||
this.objectDepth++;
|
||||
break;
|
||||
case END_OBJECT:
|
||||
this.objectDepth--;
|
||||
break;
|
||||
case START_ARRAY:
|
||||
this.arrayDepth++;
|
||||
break;
|
||||
case END_ARRAY:
|
||||
this.arrayDepth--;
|
||||
break;
|
||||
case START_OBJECT -> this.objectDepth++;
|
||||
case END_OBJECT -> this.objectDepth--;
|
||||
case START_ARRAY -> this.arrayDepth++;
|
||||
case END_ARRAY -> this.arrayDepth--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,12 +164,9 @@ public class DefaultResponseErrorHandler implements ResponseErrorHandler {
|
||||
String message = getErrorMessage(statusCode.value(), statusText, body, charset);
|
||||
|
||||
switch (statusCode.series()) {
|
||||
case CLIENT_ERROR:
|
||||
throw HttpClientErrorException.create(message, statusCode, statusText, headers, body, charset);
|
||||
case SERVER_ERROR:
|
||||
throw HttpServerErrorException.create(message, statusCode, statusText, headers, body, charset);
|
||||
default:
|
||||
throw new UnknownHttpStatusCodeException(message, statusCode.value(), statusText, headers, body, charset);
|
||||
case CLIENT_ERROR -> throw HttpClientErrorException.create(message, statusCode, statusText, headers, body, charset);
|
||||
case SERVER_ERROR -> throw HttpServerErrorException.create(message, statusCode, statusText, headers, body, charset);
|
||||
default -> throw new UnknownHttpStatusCodeException(message, statusCode.value(), statusText, headers, body, charset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -154,20 +154,11 @@ public class MockPageContext extends PageContext {
|
||||
public void setAttribute(String name, @Nullable Object value, int scope) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
switch (scope) {
|
||||
case PAGE_SCOPE:
|
||||
setAttribute(name, value);
|
||||
break;
|
||||
case REQUEST_SCOPE:
|
||||
this.request.setAttribute(name, value);
|
||||
break;
|
||||
case SESSION_SCOPE:
|
||||
this.request.getSession().setAttribute(name, value);
|
||||
break;
|
||||
case APPLICATION_SCOPE:
|
||||
this.servletContext.setAttribute(name, value);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid scope: " + scope);
|
||||
case PAGE_SCOPE -> setAttribute(name, value);
|
||||
case REQUEST_SCOPE -> this.request.setAttribute(name, value);
|
||||
case SESSION_SCOPE -> this.request.getSession().setAttribute(name, value);
|
||||
case APPLICATION_SCOPE -> this.servletContext.setAttribute(name, value);
|
||||
default -> throw new IllegalArgumentException("Invalid scope: " + scope);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,20 +217,11 @@ public class MockPageContext extends PageContext {
|
||||
public void removeAttribute(String name, int scope) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
switch (scope) {
|
||||
case PAGE_SCOPE:
|
||||
this.attributes.remove(name);
|
||||
break;
|
||||
case REQUEST_SCOPE:
|
||||
this.request.removeAttribute(name);
|
||||
break;
|
||||
case SESSION_SCOPE:
|
||||
this.request.getSession().removeAttribute(name);
|
||||
break;
|
||||
case APPLICATION_SCOPE:
|
||||
this.servletContext.removeAttribute(name);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid scope: " + scope);
|
||||
case PAGE_SCOPE -> this.attributes.remove(name);
|
||||
case REQUEST_SCOPE -> this.request.removeAttribute(name);
|
||||
case SESSION_SCOPE -> this.request.getSession().removeAttribute(name);
|
||||
case APPLICATION_SCOPE -> this.servletContext.removeAttribute(name);
|
||||
default -> throw new IllegalArgumentException("Invalid scope: " + scope);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user