Polish FileSystemResource

This commit is contained in:
Sam Brannen
2022-10-07 14:01:07 +02:00
parent 7175c4ca9a
commit 23b3fc7f3c

View File

@@ -161,6 +161,7 @@ public class FileSystemResource extends AbstractResource implements WritableReso
/**
* This implementation returns whether the underlying file exists.
* @see java.io.File#exists()
* @see java.nio.file.Files#exists(Path, java.nio.file.LinkOption...)
*/
@Override
public boolean exists() {
@@ -172,6 +173,8 @@ public class FileSystemResource extends AbstractResource implements WritableReso
* (and corresponds to an actual file with content, not to a directory).
* @see java.io.File#canRead()
* @see java.io.File#isDirectory()
* @see java.nio.file.Files#isReadable(Path)
* @see java.nio.file.Files#isDirectory(Path, java.nio.file.LinkOption...)
*/
@Override
public boolean isReadable() {
@@ -180,8 +183,8 @@ public class FileSystemResource extends AbstractResource implements WritableReso
}
/**
* This implementation opens a NIO file stream for the underlying file.
* @see java.io.FileInputStream
* This implementation opens an NIO file stream for the underlying file.
* @see java.nio.file.Files#newInputStream(Path, java.nio.file.OpenOption...)
*/
@Override
public InputStream getInputStream() throws IOException {
@@ -198,6 +201,8 @@ public class FileSystemResource extends AbstractResource implements WritableReso
* (and corresponds to an actual file with content, not to a directory).
* @see java.io.File#canWrite()
* @see java.io.File#isDirectory()
* @see java.nio.file.Files#isWritable(Path)
* @see java.nio.file.Files#isDirectory(Path, java.nio.file.LinkOption...)
*/
@Override
public boolean isWritable() {
@@ -207,7 +212,7 @@ public class FileSystemResource extends AbstractResource implements WritableReso
/**
* This implementation opens a FileOutputStream for the underlying file.
* @see java.io.FileOutputStream
* @see java.nio.file.Files#newOutputStream(Path, java.nio.file.OpenOption...)
*/
@Override
public OutputStream getOutputStream() throws IOException {
@@ -217,6 +222,7 @@ public class FileSystemResource extends AbstractResource implements WritableReso
/**
* This implementation returns a URL for the underlying file.
* @see java.io.File#toURI()
* @see java.nio.file.Path#toUri()
*/
@Override
public URL getURL() throws IOException {
@@ -226,6 +232,7 @@ public class FileSystemResource extends AbstractResource implements WritableReso
/**
* This implementation returns a URI for the underlying file.
* @see java.io.File#toURI()
* @see java.nio.file.Path#toUri()
*/
@Override
public URI getURI() throws IOException {
@@ -343,6 +350,7 @@ public class FileSystemResource extends AbstractResource implements WritableReso
/**
* This implementation returns the name of the file.
* @see java.io.File#getName()
* @see java.nio.file.Path#getFileName()
*/
@Override
public String getFilename() {
@@ -353,6 +361,7 @@ public class FileSystemResource extends AbstractResource implements WritableReso
* This implementation returns a description that includes the absolute
* path of the file.
* @see java.io.File#getAbsolutePath()
* @see java.nio.file.Path#toAbsolutePath()
*/
@Override
public String getDescription() {
@@ -361,16 +370,18 @@ public class FileSystemResource extends AbstractResource implements WritableReso
/**
* This implementation compares the underlying File references.
* This implementation compares the underlying file paths.
* @see #getPath()
*/
@Override
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof FileSystemResource &&
this.path.equals(((FileSystemResource) other).path)));
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof FileSystemResource other &&
this.path.equals(other.path)));
}
/**
* This implementation returns the hash code of the underlying File reference.
* This implementation returns the hash code of the underlying file path.
* @see #getPath()
*/
@Override
public int hashCode() {