Skip to content

Commit c0a1e17

Browse files
committed
Polishing
1 parent fe29e73 commit c0a1e17

11 files changed

+33
-36
lines changed

spring-core/src/main/java/org/springframework/core/io/AbstractFileResolvingResource.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,8 +56,7 @@ public boolean exists() {
5656
// Try a URL connection content-length header
5757
URLConnection con = url.openConnection();
5858
customizeConnection(con);
59-
HttpURLConnection httpCon =
60-
(con instanceof HttpURLConnection ? (HttpURLConnection) con : null);
59+
HttpURLConnection httpCon = (con instanceof HttpURLConnection huc ? huc : null);
6160
if (httpCon != null) {
6261
httpCon.setRequestMethod("HEAD");
6362
int code = httpCon.getResponseCode();

spring-core/src/main/java/org/springframework/core/io/AbstractResource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -226,9 +226,9 @@ public String getFilename() {
226226
* @see #getDescription()
227227
*/
228228
@Override
229-
public boolean equals(@Nullable Object other) {
230-
return (this == other || (other instanceof Resource &&
231-
((Resource) other).getDescription().equals(getDescription())));
229+
public boolean equals(@Nullable Object obj) {
230+
return (this == obj || (obj instanceof Resource that &&
231+
getDescription().equals(that.getDescription())));
232232
}
233233

234234
/**

spring-core/src/main/java/org/springframework/core/io/ByteArrayResource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ public String getDescription() {
129129
* @see java.util.Arrays#equals(byte[], byte[])
130130
*/
131131
@Override
132-
public boolean equals(@Nullable Object other) {
133-
return (this == other || (other instanceof ByteArrayResource &&
134-
Arrays.equals(((ByteArrayResource) other).byteArray, this.byteArray)));
132+
public boolean equals(@Nullable Object obj) {
133+
return (this == obj || (obj instanceof ByteArrayResource that &&
134+
Arrays.equals(this.byteArray, that.byteArray)));
135135
}
136136

137137
/**

spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -272,9 +272,9 @@ public boolean equals(@Nullable Object obj) {
272272
if (this == obj) {
273273
return true;
274274
}
275-
return ((obj instanceof ClassPathResource other) &&
276-
this.absolutePath.equals(other.absolutePath) &&
277-
ObjectUtils.nullSafeEquals(getClassLoader(), other.getClassLoader()));
275+
return ((obj instanceof ClassPathResource that) &&
276+
this.absolutePath.equals(that.absolutePath) &&
277+
ObjectUtils.nullSafeEquals(getClassLoader(), that.getClassLoader()));
278278
}
279279

280280
/**

spring-core/src/main/java/org/springframework/core/io/DescriptiveResource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -72,9 +72,9 @@ public String getDescription() {
7272
* This implementation compares the underlying description String.
7373
*/
7474
@Override
75-
public boolean equals(@Nullable Object other) {
76-
return (this == other || (other instanceof DescriptiveResource &&
77-
((DescriptiveResource) other).description.equals(this.description)));
75+
public boolean equals(@Nullable Object obj) {
76+
return (this == obj || (obj instanceof DescriptiveResource that &&
77+
this.description.equals(that.description)));
7878
}
7979

8080
/**

spring-core/src/main/java/org/springframework/core/io/FileSystemResource.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,7 @@ public String getDescription() {
396396
*/
397397
@Override
398398
public boolean equals(@Nullable Object obj) {
399-
return (this == obj || (obj instanceof FileSystemResource other &&
400-
this.path.equals(other.path)));
399+
return (this == obj || (obj instanceof FileSystemResource that && this.path.equals(that.path)));
401400
}
402401

403402
/**

spring-core/src/main/java/org/springframework/core/io/InputStreamResource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -115,9 +115,9 @@ public String getDescription() {
115115
* This implementation compares the underlying InputStream.
116116
*/
117117
@Override
118-
public boolean equals(@Nullable Object other) {
119-
return (this == other || (other instanceof InputStreamResource &&
120-
((InputStreamResource) other).inputStream.equals(this.inputStream)));
118+
public boolean equals(@Nullable Object obj) {
119+
return (this == obj || (obj instanceof InputStreamResource that &&
120+
this.inputStream.equals(that.inputStream)));
121121
}
122122

123123
/**

spring-core/src/main/java/org/springframework/core/io/PathResource.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,8 @@ public String getDescription() {
298298
* This implementation compares the underlying Path references.
299299
*/
300300
@Override
301-
public boolean equals(@Nullable Object other) {
302-
return (this == other || (other instanceof PathResource &&
303-
this.path.equals(((PathResource) other).path)));
301+
public boolean equals(@Nullable Object obj) {
302+
return (this == obj || (obj instanceof PathResource that && this.path.equals(that.path)));
304303
}
305304

306305
/**

spring-core/src/main/java/org/springframework/core/io/UrlResource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -343,9 +343,9 @@ public String getDescription() {
343343
* This implementation compares the underlying URL references.
344344
*/
345345
@Override
346-
public boolean equals(@Nullable Object other) {
347-
return (this == other || (other instanceof UrlResource resource &&
348-
getCleanedUrl().equals(resource.getCleanedUrl())));
346+
public boolean equals(@Nullable Object obj) {
347+
return (this == obj || (obj instanceof UrlResource that &&
348+
getCleanedUrl().equals(that.getCleanedUrl())));
349349
}
350350

351351
/**

spring-core/src/main/java/org/springframework/core/io/VfsResource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -130,9 +130,9 @@ public String getDescription() {
130130
}
131131

132132
@Override
133-
public boolean equals(@Nullable Object other) {
134-
return (this == other || (other instanceof VfsResource &&
135-
this.resource.equals(((VfsResource) other).resource)));
133+
public boolean equals(@Nullable Object obj) {
134+
return (this == obj || (obj instanceof VfsResource that &&
135+
this.resource.equals(that.resource)));
136136
}
137137

138138
@Override

spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource
808808

809809
Set<Resource> result = new LinkedHashSet<>();
810810
try (Stream<Path> files = Files.walk(rootPath)) {
811-
files.filter(isMatchingFile).sorted().forEach(file -> result.add(new FileSystemResource(file)));
811+
files.filter(isMatchingFile).sorted().map(FileSystemResource::new).forEach(result::add);
812812
}
813813
catch (Exception ex) {
814814
if (logger.isWarnEnabled()) {

0 commit comments

Comments
 (0)