This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit 7387d242272dcae8392f49826a3825096c687708 Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Tue Jul 26 09:04:31 2022 -0400 Sort main members --- .../org/apache/commons/io/file/FilesUncheck.java | 34 +++++++++---------- .../java/org/apache/commons/io/file/PathUtils.java | 10 +++--- .../apache/commons/io/function/IOBiFunction.java | 20 ++++++------ .../apache/commons/io/function/IOQuadFunction.java | 24 +++++++------- .../apache/commons/io/function/IOTriFunction.java | 22 ++++++------- .../input/MessageDigestCalculatingInputStream.java | 38 +++++++++++----------- .../org/apache/commons/io/monitor/FileEntry.java | 8 ++--- .../apache/commons/io/output/XmlStreamWriter.java | 12 +++---- 8 files changed, 84 insertions(+), 84 deletions(-) diff --git a/src/main/java/org/apache/commons/io/file/FilesUncheck.java b/src/main/java/org/apache/commons/io/file/FilesUncheck.java index 8a406278..f3cd712d 100644 --- a/src/main/java/org/apache/commons/io/file/FilesUncheck.java +++ b/src/main/java/org/apache/commons/io/file/FilesUncheck.java @@ -468,27 +468,27 @@ public class FilesUncheck { } /** - * Delegates to {@link Files#newDirectoryStream(Path, String)} throwing {@link UncheckedIOException} instead of - * {@link IOException}. + * Delegates to {@link Files#newDirectoryStream(Path, java.nio.file.DirectoryStream.Filter)} throwing + * {@link UncheckedIOException} instead of {@link IOException}. * * @param dir See delegate. - * @param glob See delegate. + * @param filter See delegate. * @return See delegate. */ - public static DirectoryStream<Path> newDirectoryStream(final Path dir, final String glob) { - return Uncheck.apply(Files::newDirectoryStream, dir, glob); + public static DirectoryStream<Path> newDirectoryStream(final Path dir, final DirectoryStream.Filter<? super Path> filter) { + return Uncheck.apply(Files::newDirectoryStream, dir, filter); } /** - * Delegates to {@link Files#newDirectoryStream(Path, java.nio.file.DirectoryStream.Filter)} throwing - * {@link UncheckedIOException} instead of {@link IOException}. + * Delegates to {@link Files#newDirectoryStream(Path, String)} throwing {@link UncheckedIOException} instead of + * {@link IOException}. * * @param dir See delegate. - * @param filter See delegate. + * @param glob See delegate. * @return See delegate. */ - public static DirectoryStream<Path> newDirectoryStream(final Path dir, final DirectoryStream.Filter<? super Path> filter) { - return Uncheck.apply(Files::newDirectoryStream, dir, filter); + public static DirectoryStream<Path> newDirectoryStream(final Path dir, final String glob) { + return Uncheck.apply(Files::newDirectoryStream, dir, glob); } /** @@ -657,28 +657,28 @@ public class FilesUncheck { } /** - * Delegates to {@link Files#walk(Path, int, FileVisitOption...)} throwing {@link UncheckedIOException} instead of + * Delegates to {@link Files#walk(Path, FileVisitOption...)} throwing {@link UncheckedIOException} instead of * {@link IOException}. * * @param start See delegate. - * @param maxDepth See delegate. * @param options See delegate. * @return See delegate. */ - public static Stream<Path> walk(final Path start, final int maxDepth, final FileVisitOption... options) { - return Uncheck.apply(Files::walk, start, maxDepth, options); + public static Stream<Path> walk(final Path start, final FileVisitOption... options) { + return Uncheck.apply(Files::walk, start, options); } /** - * Delegates to {@link Files#walk(Path, FileVisitOption...)} throwing {@link UncheckedIOException} instead of + * Delegates to {@link Files#walk(Path, int, FileVisitOption...)} throwing {@link UncheckedIOException} instead of * {@link IOException}. * * @param start See delegate. + * @param maxDepth See delegate. * @param options See delegate. * @return See delegate. */ - public static Stream<Path> walk(final Path start, final FileVisitOption... options) { - return Uncheck.apply(Files::walk, start, options); + public static Stream<Path> walk(final Path start, final int maxDepth, final FileVisitOption... options) { + return Uncheck.apply(Files::walk, start, maxDepth, options); } /** diff --git a/src/main/java/org/apache/commons/io/file/PathUtils.java b/src/main/java/org/apache/commons/io/file/PathUtils.java index 59e45532..b504c4a3 100644 --- a/src/main/java/org/apache/commons/io/file/PathUtils.java +++ b/src/main/java/org/apache/commons/io/file/PathUtils.java @@ -836,27 +836,27 @@ public final class PathUtils { * Gets the file's last modified time or null if the file does not exist. * * @param path the file to query. + * @param defaultIfAbsent Returns this file time of the file does not exist, may be null. * @param options options indicating how symbolic links are handled. * @return the file's last modified time. * @throws IOException Thrown if an I/O error occurs. * @since 2.12.0 */ - public static FileTime getLastModifiedFileTime(final Path path, final LinkOption... options) throws IOException { - return getLastModifiedFileTime(path, null, options); + public static FileTime getLastModifiedFileTime(final Path path, final FileTime defaultIfAbsent, final LinkOption... options) throws IOException { + return Files.exists(path) ? getLastModifiedTime(path, options) : defaultIfAbsent; } /** * Gets the file's last modified time or null if the file does not exist. * * @param path the file to query. - * @param defaultIfAbsent Returns this file time of the file does not exist, may be null. * @param options options indicating how symbolic links are handled. * @return the file's last modified time. * @throws IOException Thrown if an I/O error occurs. * @since 2.12.0 */ - public static FileTime getLastModifiedFileTime(final Path path, final FileTime defaultIfAbsent, final LinkOption... options) throws IOException { - return Files.exists(path) ? getLastModifiedTime(path, options) : defaultIfAbsent; + public static FileTime getLastModifiedFileTime(final Path path, final LinkOption... options) throws IOException { + return getLastModifiedFileTime(path, null, options); } /** diff --git a/src/main/java/org/apache/commons/io/function/IOBiFunction.java b/src/main/java/org/apache/commons/io/function/IOBiFunction.java index aed614b2..cc5afdb9 100644 --- a/src/main/java/org/apache/commons/io/function/IOBiFunction.java +++ b/src/main/java/org/apache/commons/io/function/IOBiFunction.java @@ -51,16 +51,6 @@ public interface IOBiFunction<T, U, R> { return Constants.IO_BI_FUNCTION; } - /** - * Applies this function to the given arguments. - * - * @param t the first function argument - * @param u the second function argument - * @return the function result - * @throws IOException if an I/O error occurs. - */ - R apply(T t, U u) throws IOException; - /** * Returns a composed function that first applies this function to its input, and then applies the {@code after} * function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the @@ -75,4 +65,14 @@ public interface IOBiFunction<T, U, R> { Objects.requireNonNull(after); return (final T t, final U u) -> after.apply(apply(t, u)); } + + /** + * Applies this function to the given arguments. + * + * @param t the first function argument + * @param u the second function argument + * @return the function result + * @throws IOException if an I/O error occurs. + */ + R apply(T t, U u) throws IOException; } diff --git a/src/main/java/org/apache/commons/io/function/IOQuadFunction.java b/src/main/java/org/apache/commons/io/function/IOQuadFunction.java index 73916364..470d4950 100644 --- a/src/main/java/org/apache/commons/io/function/IOQuadFunction.java +++ b/src/main/java/org/apache/commons/io/function/IOQuadFunction.java @@ -41,18 +41,6 @@ import java.util.function.Function; @FunctionalInterface public interface IOQuadFunction<T, U, V, W, R> { - /** - * Applies this function to the given arguments. - * - * @param t the first function argument - * @param u the second function argument - * @param v the third function argument - * @param w the fourth function argument - * @return the function result - * @throws IOException if an I/O error occurs. - */ - R apply(T t, U u, V v, W w) throws IOException; - /** * Returns a composed function that first applies this function to its input, and then applies the {@code after} * function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the @@ -67,4 +55,16 @@ public interface IOQuadFunction<T, U, V, W, R> { Objects.requireNonNull(after); return (final T t, final U u, final V v, final W w) -> after.apply(apply(t, u, v, w)); } + + /** + * Applies this function to the given arguments. + * + * @param t the first function argument + * @param u the second function argument + * @param v the third function argument + * @param w the fourth function argument + * @return the function result + * @throws IOException if an I/O error occurs. + */ + R apply(T t, U u, V v, W w) throws IOException; } diff --git a/src/main/java/org/apache/commons/io/function/IOTriFunction.java b/src/main/java/org/apache/commons/io/function/IOTriFunction.java index c27929f2..d89ee1e8 100644 --- a/src/main/java/org/apache/commons/io/function/IOTriFunction.java +++ b/src/main/java/org/apache/commons/io/function/IOTriFunction.java @@ -40,17 +40,6 @@ import java.util.function.Function; @FunctionalInterface public interface IOTriFunction<T, U, V, R> { - /** - * Applies this function to the given arguments. - * - * @param t the first function argument - * @param u the second function argument - * @param v the third function argument - * @return the function result - * @throws IOException if an I/O error occurs. - */ - R apply(T t, U u, V v) throws IOException; - /** * Returns a composed function that first applies this function to its input, and then applies the {@code after} * function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the @@ -66,4 +55,15 @@ public interface IOTriFunction<T, U, V, R> { return (final T t, final U u, final V v) -> after.apply(apply(t, u, v)); } + /** + * Applies this function to the given arguments. + * + * @param t the first function argument + * @param u the second function argument + * @param v the third function argument + * @return the function result + * @throws IOException if an I/O error occurs. + */ + R apply(T t, U u, V v) throws IOException; + } diff --git a/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java b/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java index 5f3d54dd..5062c352 100644 --- a/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java +++ b/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java @@ -39,14 +39,6 @@ import java.security.Provider; */ public class MessageDigestCalculatingInputStream extends ObservableInputStream { - /** - * The default message digest algorithm. - * <p> - * The MD5 cryptographic algorithm is weak and should not be used. - * </p> - */ - private static final String DEFAULT_ALGORITHM = "MD5"; - /** * Maintains the message digest. */ @@ -72,6 +64,25 @@ public class MessageDigestCalculatingInputStream extends ObservableInputStream { } } + /** + * The default message digest algorithm. + * <p> + * The MD5 cryptographic algorithm is weak and should not be used. + * </p> + */ + private static final String DEFAULT_ALGORITHM = "MD5"; + + /** + * Gets a MessageDigest object that implements the default digest algorithm. + * + * @return a Message Digest object that implements the default algorithm. + * @throws NoSuchAlgorithmException if no Provider supports a MessageDigestSpi implementation. + * @see Provider + */ + static MessageDigest getDefaultMessageDigest() throws NoSuchAlgorithmException { + return MessageDigest.getInstance(DEFAULT_ALGORITHM); + } + private final MessageDigest messageDigest; /** @@ -117,17 +128,6 @@ public class MessageDigestCalculatingInputStream extends ObservableInputStream { this(inputStream, MessageDigest.getInstance(algorithm)); } - /** - * Gets a MessageDigest object that implements the default digest algorithm. - * - * @return a Message Digest object that implements the default algorithm. - * @throws NoSuchAlgorithmException if no Provider supports a MessageDigestSpi implementation. - * @see Provider - */ - static MessageDigest getDefaultMessageDigest() throws NoSuchAlgorithmException { - return MessageDigest.getInstance(DEFAULT_ALGORITHM); - } - /** * Gets the {@link MessageDigest}, which is being used for generating the * checksum. diff --git a/src/main/java/org/apache/commons/io/monitor/FileEntry.java b/src/main/java/org/apache/commons/io/monitor/FileEntry.java index 819892a5..773e1752 100644 --- a/src/main/java/org/apache/commons/io/monitor/FileEntry.java +++ b/src/main/java/org/apache/commons/io/monitor/FileEntry.java @@ -269,10 +269,6 @@ public class FileEntry implements Serializable { setLastModified(new SerializableFileTime(lastModified)); } - void setLastModified(final SerializableFileTime lastModified) { - this.lastModified = lastModified; - } - /** * Sets the last modified time from the last time it * was checked. @@ -283,6 +279,10 @@ public class FileEntry implements Serializable { setLastModified(FileTime.fromMillis(lastModified)); } + void setLastModified(final SerializableFileTime lastModified) { + this.lastModified = lastModified; + } + /** * Sets the length. * diff --git a/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java b/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java index 37233fff..ab55e093 100644 --- a/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java +++ b/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java @@ -97,9 +97,11 @@ public class XmlStreamWriter extends Writer { * * @param out The output stream * @param defaultEncoding The default encoding if not encoding could be detected + * @since 2.12.0 */ - public XmlStreamWriter(final OutputStream out, final String defaultEncoding) { - this(out, Charsets.toCharset(defaultEncoding, StandardCharsets.UTF_8)); + public XmlStreamWriter(final OutputStream out, final Charset defaultEncoding) { + this.out = out; + this.defaultCharset = Objects.requireNonNull(defaultEncoding); } /** @@ -108,11 +110,9 @@ public class XmlStreamWriter extends Writer { * * @param out The output stream * @param defaultEncoding The default encoding if not encoding could be detected - * @since 2.12.0 */ - public XmlStreamWriter(final OutputStream out, final Charset defaultEncoding) { - this.out = out; - this.defaultCharset = Objects.requireNonNull(defaultEncoding); + public XmlStreamWriter(final OutputStream out, final String defaultEncoding) { + this(out, Charsets.toCharset(defaultEncoding, StandardCharsets.UTF_8)); } /**