Always use 'this.' when accessing fields

Ensure that `this.` is used consistently when accessing class
fields.

Issue: SPR-16968
This commit is contained in:
Phillip Webb
2018-06-25 11:37:17 -07:00
committed by Juergen Hoeller
parent eeebd51f57
commit 0b53c1096a
154 changed files with 374 additions and 373 deletions

View File

@@ -177,9 +177,9 @@ public final class ContentDisposition {
result = 31 * result + ObjectUtils.nullSafeHashCode(this.filename);
result = 31 * result + ObjectUtils.nullSafeHashCode(this.charset);
result = 31 * result + ObjectUtils.nullSafeHashCode(this.size);
result = 31 * result + (creationDate != null ? creationDate.hashCode() : 0);
result = 31 * result + (modificationDate != null ? modificationDate.hashCode() : 0);
result = 31 * result + (readDate != null ? readDate.hashCode() : 0);
result = 31 * result + (this.creationDate != null ? this.creationDate.hashCode() : 0);
result = 31 * result + (this.modificationDate != null ? this.modificationDate.hashCode() : 0);
result = 31 * result + (this.readDate != null ? this.readDate.hashCode() : 0);
return result;
}

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.
@@ -85,7 +85,7 @@ class InterceptingAsyncClientHttpRequest extends AbstractBufferingAsyncClientHtt
@Override
public URI getURI() {
return uri;
return this.uri;
}

View File

@@ -138,7 +138,7 @@ class Netty4ClientHttpRequest extends AbstractAsyncClientHttpRequest implements
FullHttpRequest nettyRequest = new DefaultFullHttpRequest(
HttpVersion.HTTP_1_1, nettyMethod, path, this.body.buffer());
nettyRequest.headers().set(HttpHeaders.HOST, this.uri.getHost() + ":" + getPort(uri));
nettyRequest.headers().set(HttpHeaders.HOST, this.uri.getHost() + ":" + getPort(this.uri));
nettyRequest.headers().set(HttpHeaders.CONNECTION, "close");
headers.forEach((headerName, headerValues) -> nettyRequest.headers().add(headerName, headerValues));
if (!nettyRequest.headers().contains(HttpHeaders.CONTENT_LENGTH) && this.body.buffer().readableBytes() > 0) {

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.
@@ -66,7 +66,7 @@ public class AsyncHttpAccessor {
* org.springframework.http.client.ClientHttpRequest HttpRequests}.
*/
public org.springframework.http.client.AsyncClientHttpRequestFactory getAsyncRequestFactory() {
Assert.state(asyncRequestFactory != null, "No AsyncClientHttpRequestFactory set");
Assert.state(this.asyncRequestFactory != null, "No AsyncClientHttpRequestFactory set");
return this.asyncRequestFactory;
}

View File

@@ -150,7 +150,7 @@ public class MultipartHttpMessageWriter extends LoggingCodecSupport
* @since 5.0.7
*/
public List<HttpMessageWriter<?>> getPartWriters() {
return Collections.unmodifiableList(partWriters);
return Collections.unmodifiableList(this.partWriters);
}
/**
@@ -398,7 +398,7 @@ public class MultipartHttpMessageWriter extends LoggingCodecSupport
private DataBuffer generateHeaders() {
DataBuffer buffer = this.bufferFactory.allocateBuffer();
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
for (Map.Entry<String, List<String>> entry : this.headers.entrySet()) {
byte[] headerName = entry.getKey().getBytes(this.charset);
for (String headerValueString : entry.getValue()) {
byte[] headerValue = headerValueString.getBytes(this.charset);

View File

@@ -142,7 +142,7 @@ public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
NioMultipartParserListener listener = new FluxSinkAdapterListener(emitter, this.bufferFactory, context);
NioMultipartParser parser = Multipart
.multipart(context)
.usePartBodyStreamStorageFactory(streamStorageFactory)
.usePartBodyStreamStorageFactory(this.streamStorageFactory)
.forNIO(listener);
this.inputMessage.getBody().subscribe(buffer -> {

View File

@@ -97,7 +97,7 @@ public class XmlEventDecoder extends AbstractDecoder<XMLEvent> {
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
Flux<DataBuffer> flux = Flux.from(inputStream);
if (useAalto) {
if (this.useAalto) {
AaltoDataBufferToXmlEvent aaltoMapper = new AaltoDataBufferToXmlEvent();
return flux.flatMap(aaltoMapper)
.doFinally(signalType -> aaltoMapper.endOfInput());
@@ -135,15 +135,15 @@ public class XmlEventDecoder extends AbstractDecoder<XMLEvent> {
@Override
public Publisher<? extends XMLEvent> apply(DataBuffer dataBuffer) {
try {
streamReader.getInputFeeder().feedInput(dataBuffer.asByteBuffer());
this.streamReader.getInputFeeder().feedInput(dataBuffer.asByteBuffer());
List<XMLEvent> events = new ArrayList<>();
while (true) {
if (streamReader.next() == AsyncXMLStreamReader.EVENT_INCOMPLETE) {
if (this.streamReader.next() == AsyncXMLStreamReader.EVENT_INCOMPLETE) {
// no more events with what currently has been fed to the reader
break;
}
else {
XMLEvent event = eventAllocator.allocate(streamReader);
XMLEvent event = this.eventAllocator.allocate(this.streamReader);
events.add(event);
if (event.isEndDocument()) {
break;

View File

@@ -204,7 +204,7 @@ public class BufferedImageHttpMessageConverter implements HttpMessageConverter<B
private ImageInputStream createImageInputStream(InputStream is) throws IOException {
if (this.cacheDir != null) {
return new FileCacheImageInputStream(is, cacheDir);
return new FileCacheImageInputStream(is, this.cacheDir);
}
else {
return new MemoryCacheImageInputStream(is);

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.
@@ -96,7 +96,7 @@ public class ConfigurableWebBindingInitializer implements WebBindingInitializer
* Return whether to use direct field access instead of bean property access.
*/
public boolean isDirectFieldAccess() {
return directFieldAccess;
return this.directFieldAccess;
}
/**

View File

@@ -234,7 +234,7 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter {
int port = uriComponents.getPort();
this.scheme = uriComponents.getScheme();
this.secure = "https".equals(scheme);
this.secure = "https".equals(this.scheme);
this.host = uriComponents.getHost();
this.port = (port == -1 ? (this.secure ? 443 : 80) : port);

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.
@@ -66,6 +66,6 @@ public class MethodNotAllowedException extends ResponseStatusException {
* Return the list of supported HTTP methods.
*/
public Set<HttpMethod> getSupportedMethods() {
return supportedMethods;
return this.supportedMethods;
}
}

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.
@@ -88,7 +88,7 @@ public class ResponseStatusException extends NestedRuntimeException {
@Override
public String getMessage() {
String msg = this.status + (this.reason != null ? " \"" + reason + "\"" : "");
String msg = this.status + (this.reason != null ? " \"" + this.reason + "\"" : "");
return NestedExceptionUtils.buildMessage(msg, getCause());
}

View File

@@ -76,7 +76,7 @@ class CaptureTheRestPathElement extends PathElement {
}
}
}
matchingContext.set(variableName, pathToString(pathIndex, matchingContext.pathElements),
matchingContext.set(this.variableName, pathToString(pathIndex, matchingContext.pathElements),
parametersCollector == null?NO_PARAMETERS:parametersCollector);
}
return true;

View File

@@ -85,7 +85,7 @@ class CaptureVariablePathElement extends PathElement {
if (this.constraintPattern != null) {
// TODO possible optimization - only regex match if rest of pattern matches?
// Benefit likely to vary pattern to pattern
Matcher matcher = constraintPattern.matcher(candidateCapture);
Matcher matcher = this.constraintPattern.matcher(candidateCapture);
if (matcher.groupCount() != 0) {
throw new IllegalArgumentException(
"No capture groups allowed in the constraint regex: " + this.constraintPattern.pattern());

View File

@@ -135,7 +135,7 @@ class InternalPathPatternParser {
// throw new PatternParseException(pos, pathPatternData,
// PatternMessage.CANNOT_HAVE_ADJACENT_CAPTURES);
this.insideVariableCapture = true;
this.variableCaptureStart = pos;
this.variableCaptureStart = this.pos;
}
else if (ch == '}') {
if (!this.insideVariableCapture) {
@@ -202,7 +202,7 @@ class InternalPathPatternParser {
boolean previousBackslash = false;
while (this.pos < this.pathPatternLength) {
char ch = this.pathPatternData[pos];
char ch = this.pathPatternData[this.pos];
if (ch == '\\' && !previousBackslash) {
this.pos++;
previousBackslash = true;

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.
@@ -46,7 +46,7 @@ class LiteralPathElement extends PathElement {
else {
// Force all the text lower case to make matching faster
this.text = new char[literalText.length];
for (int i = 0; i < len; i++) {
for (int i = 0; i < this.len; i++) {
this.text[i] = Character.toLowerCase(literalText[i]);
}
}
@@ -64,21 +64,21 @@ class LiteralPathElement extends PathElement {
return false;
}
String value = ((PathSegment)element).valueToMatch();
if (value.length() != len) {
if (value.length() != this.len) {
// Not enough data to match this path element
return false;
}
char[] data = ((PathContainer.PathSegment)element).valueToMatchAsChars();
if (this.caseSensitive) {
for (int i = 0; i < len; i++) {
for (int i = 0; i < this.len; i++) {
if (data[i] != this.text[i]) {
return false;
}
}
}
else {
for (int i = 0; i < len; i++) {
for (int i = 0; i < this.len; i++) {
// TODO revisit performance if doing a lot of case insensitive matching
if (Character.toLowerCase(data[i]) != this.text[i]) {
return false;

View File

@@ -282,7 +282,7 @@ public class PathPattern implements Comparable<PathPattern> {
int startIndex = 0;
// Find first path element that is not a separator or a literal (i.e. the first pattern based element)
PathElement elem = head;
PathElement elem = this.head;
while (elem != null) {
if (elem.getWildcardCount() != 0 || elem.getCaptureCount() != 0) {
break;
@@ -358,7 +358,7 @@ public class PathPattern implements Comparable<PathPattern> {
// If one of them is empty the result is the other. If both empty the result is ""
if (!StringUtils.hasLength(this.patternString)) {
if (!StringUtils.hasLength(pattern2string.patternString)) {
return parser.parse("");
return this.parser.parse("");
}
else {
return pattern2string;
@@ -381,7 +381,7 @@ public class PathPattern implements Comparable<PathPattern> {
// /hotels/* + /booking => /hotels/booking
// /hotels/* + booking => /hotels/booking
if (this.endsWithSeparatorWildcard) {
return parser.parse(concat(
return this.parser.parse(concat(
this.patternString.substring(0, this.patternString.length() - 2),
pattern2string.patternString));
}
@@ -390,7 +390,7 @@ public class PathPattern implements Comparable<PathPattern> {
// /hotels + booking => /hotels/booking
int starDotPos1 = this.patternString.indexOf("*."); // Are there any file prefix/suffix things to consider?
if (this.capturedVariableCount != 0 || starDotPos1 == -1 || this.separator == '.') {
return parser.parse(concat(this.patternString, pattern2string.patternString));
return this.parser.parse(concat(this.patternString, pattern2string.patternString));
}
// /*.html + /hotel => /hotel.html
@@ -406,7 +406,7 @@ public class PathPattern implements Comparable<PathPattern> {
throw new IllegalArgumentException(
"Cannot combine patterns: " + this.patternString + " and " + pattern2string);
}
return parser.parse(file2 + (firstExtensionWild ? secondExtension : firstExtension));
return this.parser.parse(file2 + (firstExtensionWild ? secondExtension : firstExtension));
}
public boolean equals(Object other) {
@@ -519,7 +519,7 @@ public class PathPattern implements Comparable<PathPattern> {
private boolean pathContainerIsJustSeparator(PathContainer pathContainer) {
return pathContainer.value().length() == 1 &&
pathContainer.value().charAt(0) == separator;
pathContainer.value().charAt(0) == this.separator;
}
/**
@@ -643,14 +643,14 @@ public class PathPattern implements Comparable<PathPattern> {
int remainingPathIndex;
public MatchingContext(PathContainer pathContainer, boolean extractVariables) {
candidate = pathContainer;
pathElements = pathContainer.elements();
pathLength = pathElements.size();
this.candidate = pathContainer;
this.pathElements = pathContainer.elements();
this.pathLength = this.pathElements.size();
this.extractingVariables = extractVariables;
}
public void setMatchAllowExtraPath() {
determineRemainingPath = true;
this.determineRemainingPath = true;
}
public boolean isMatchOptionalTrailingSeparator() {
@@ -686,7 +686,7 @@ public class PathPattern implements Comparable<PathPattern> {
* @return {@code true} if element is a separator
*/
boolean isSeparator(int pathIndex) {
return pathElements.get(pathIndex) instanceof Separator;
return this.pathElements.get(pathIndex) instanceof Separator;
}
/**
@@ -695,7 +695,7 @@ public class PathPattern implements Comparable<PathPattern> {
* @return the decoded value
*/
String pathElementValue(int pathIndex) {
Element element = (pathIndex < pathLength) ? pathElements.get(pathIndex) : null;
Element element = (pathIndex < this.pathLength) ? this.pathElements.get(pathIndex) : null;
if (element instanceof PathContainer.PathSegment) {
return ((PathContainer.PathSegment)element).valueToMatch();
}

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.
@@ -50,7 +50,7 @@ class SingleCharWildcardedPathElement extends PathElement {
}
else {
this.text = new char[literalText.length];
for (int i = 0; i < len; i++) {
for (int i = 0; i < this.len; i++) {
this.text[i] = Character.toLowerCase(literalText[i]);
}
}
@@ -69,14 +69,14 @@ class SingleCharWildcardedPathElement extends PathElement {
return false;
}
String value = ((PathSegment)element).valueToMatch();
if (value.length() != len) {
if (value.length() != this.len) {
// Not enough data to match this path element
return false;
}
char[] data = ((PathSegment)element).valueToMatchAsChars();
if (this.caseSensitive) {
for (int i = 0; i < len; i++) {
for (int i = 0; i < this.len; i++) {
char ch = this.text[i];
if ((ch != '?') && (ch != data[i])) {
return false;
@@ -84,7 +84,7 @@ class SingleCharWildcardedPathElement extends PathElement {
}
}
else {
for (int i = 0; i < len; i++) {
for (int i = 0; i < this.len; i++) {
char ch = this.text[i];
// TODO revisit performance if doing a lot of case insensitive matching
if ((ch != '?') && (ch != Character.toLowerCase(data[i]))) {
@@ -122,7 +122,7 @@ class SingleCharWildcardedPathElement extends PathElement {
@Override
public int getNormalizedLength() {
return len;
return this.len;
}