Polishing

This commit is contained in:
Juergen Hoeller
2018-06-28 14:51:31 +02:00
parent b68e692854
commit 40efcc933c
107 changed files with 510 additions and 624 deletions

View File

@@ -101,9 +101,9 @@ public final class MultipartBodyBuilder {
HttpHeaders partHeaders = new HttpHeaders();
if (part instanceof HttpEntity) {
HttpEntity<?> other = (HttpEntity<?>) part;
partBody = other.getBody();
partHeaders.addAll(other.getHeaders());
HttpEntity<?> httpEntity = (HttpEntity<?>) part;
partBody = httpEntity.getBody();
partHeaders.addAll(httpEntity.getHeaders());
}
else {
partBody = part;

View File

@@ -18,6 +18,7 @@ package org.springframework.http.codec;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -50,8 +51,6 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.MimeTypeUtils;
import static java.util.Collections.emptyMap;
/**
* {@code HttpMessageWriter} that can write a {@link Resource}.
*
@@ -244,7 +243,7 @@ public class ResourceHttpMessageWriter implements HttpMessageWriter<Resource> {
.orElseGet(() -> {
Publisher<? extends ResourceRegion> input = Mono.just(region);
MediaType mediaType = message.getHeaders().getContentType();
return encodeAndWriteRegions(input, mediaType, message, emptyMap());
return encodeAndWriteRegions(input, mediaType, message, Collections.emptyMap());
});
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -132,10 +132,10 @@ class DefaultRequestPath implements RequestPath {
if (other == null || getClass() != other.getClass()) {
return false;
}
DefaultRequestPath that = (DefaultRequestPath) other;
return (this.fullPath.equals(that.fullPath) &&
this.contextPath.equals(that.contextPath) &&
this.pathWithinApplication.equals(that.pathWithinApplication));
DefaultRequestPath otherPath= (DefaultRequestPath) other;
return (this.fullPath.equals(otherPath.fullPath) &&
this.contextPath.equals(otherPath.contextPath) &&
this.pathWithinApplication.equals(otherPath.pathWithinApplication));
}
@Override

View File

@@ -236,15 +236,15 @@ public class ServletContextResource extends AbstractFileResolvingResource implem
* This implementation compares the underlying ServletContext resource locations.
*/
@Override
public boolean equals(Object obj) {
if (obj == this) {
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (obj instanceof ServletContextResource) {
ServletContextResource otherRes = (ServletContextResource) obj;
return (this.servletContext.equals(otherRes.servletContext) && this.path.equals(otherRes.path));
if (!(other instanceof ServletContextResource)) {
return false;
}
return false;
ServletContextResource otherRes = (ServletContextResource) other;
return (this.servletContext.equals(otherRes.servletContext) && this.path.equals(otherRes.path));
}
/**

View File

@@ -86,9 +86,9 @@ class MultipartFileResource extends AbstractResource {
@Override
public boolean equals(Object obj) {
return (obj == this || (obj instanceof MultipartFileResource &&
((MultipartFileResource) obj).multipartFile.equals(this.multipartFile)));
public boolean equals(Object other) {
return (this == other || (other instanceof MultipartFileResource &&
((MultipartFileResource) other).multipartFile.equals(this.multipartFile)));
}
@Override

View File

@@ -53,6 +53,7 @@ final class HierarchicalUriComponents extends UriComponents {
private static final String PATH_DELIMITER_STRING = "/";
/**
* Represents an empty path.
*/
@@ -87,8 +88,8 @@ final class HierarchicalUriComponents extends UriComponents {
}
@Override
public boolean equals(Object obj) {
return (this == obj);
public boolean equals(Object other) {
return (this == other);
}
@Override
@@ -506,21 +507,21 @@ final class HierarchicalUriComponents extends UriComponents {
@Override
public boolean equals(Object obj) {
if (this == obj) {
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(obj instanceof HierarchicalUriComponents)) {
if (!(other instanceof HierarchicalUriComponents)) {
return false;
}
HierarchicalUriComponents other = (HierarchicalUriComponents) obj;
return ObjectUtils.nullSafeEquals(getScheme(), other.getScheme()) &&
ObjectUtils.nullSafeEquals(getUserInfo(), other.getUserInfo()) &&
ObjectUtils.nullSafeEquals(getHost(), other.getHost()) &&
getPort() == other.getPort() &&
this.path.equals(other.path) &&
this.queryParams.equals(other.queryParams) &&
ObjectUtils.nullSafeEquals(getFragment(), other.getFragment());
HierarchicalUriComponents otherComp = (HierarchicalUriComponents) other;
return (ObjectUtils.nullSafeEquals(getScheme(), otherComp.getScheme()) &&
ObjectUtils.nullSafeEquals(getUserInfo(), otherComp.getUserInfo()) &&
ObjectUtils.nullSafeEquals(getHost(), otherComp.getHost()) &&
getPort() == otherComp.getPort() &&
this.path.equals(otherComp.path) &&
this.queryParams.equals(otherComp.queryParams) &&
ObjectUtils.nullSafeEquals(getFragment(), otherComp.getFragment()));
}
@Override
@@ -752,9 +753,9 @@ final class HierarchicalUriComponents extends UriComponents {
}
@Override
public boolean equals(Object obj) {
return (this == obj || (obj instanceof FullPathComponent &&
getPath().equals(((FullPathComponent) obj).getPath())));
public boolean equals(Object other) {
return (this == other || (other instanceof FullPathComponent &&
getPath().equals(((FullPathComponent) other).getPath())));
}
@Override
@@ -830,9 +831,9 @@ final class HierarchicalUriComponents extends UriComponents {
}
@Override
public boolean equals(Object obj) {
return (this == obj || (obj instanceof PathSegmentComponent &&
getPathSegments().equals(((PathSegmentComponent) obj).getPathSegments())));
public boolean equals(Object other) {
return (this == other || (other instanceof PathSegmentComponent &&
getPathSegments().equals(((PathSegmentComponent) other).getPathSegments())));
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -157,19 +157,17 @@ final class OpaqueUriComponents extends UriComponents {
@Override
public boolean equals(Object obj) {
if (this == obj) {
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(obj instanceof OpaqueUriComponents)) {
if (!(other instanceof OpaqueUriComponents)) {
return false;
}
OpaqueUriComponents other = (OpaqueUriComponents) obj;
return ObjectUtils.nullSafeEquals(getScheme(), other.getScheme()) &&
ObjectUtils.nullSafeEquals(this.ssp, other.ssp) &&
ObjectUtils.nullSafeEquals(getFragment(), other.getFragment());
OpaqueUriComponents otherComp = (OpaqueUriComponents) other;
return (ObjectUtils.nullSafeEquals(getScheme(), otherComp.getScheme()) &&
ObjectUtils.nullSafeEquals(this.ssp, otherComp.ssp) &&
ObjectUtils.nullSafeEquals(getFragment(), otherComp.getFragment()));
}
@Override