Skip to content

Commit 80474fe

Browse files
authored
[IO-808] more precise Javadoc about when an IllegalArgumentException is thrown (#581)
* more precise JavaDoc about when an IllegalArgumentException is thrown * more precise JavaDoc about when an IllegalArgumentException is thrown * more precise JavaDoc about when an IllegalArgumentException is thrown * more precise JavaDoc about when an IllegalArgumentException is thrown * format * javadoc
1 parent 3eba72b commit 80474fe

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

src/main/java/org/apache/commons/io/FileUtils.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,8 @@ public static File[] convertFileCollectionToFileArray(final Collection<File> fil
517517
* @param srcDir an existing directory to copy, must not be {@code null}.
518518
* @param destDir the new directory, must not be {@code null}.
519519
* @throws NullPointerException if any of the given {@link File}s are {@code null}.
520-
* @throws IllegalArgumentException if the source or destination is invalid.
520+
* @throws IllegalArgumentException if {@code srcDir} exists but is not a directory,
521+
* the source and the destination directory are the same, or the destination is not writable
521522
* @throws FileNotFoundException if the source does not exist.
522523
* @throws IOException if an error occurs or setting the last-modified time didn't succeed.
523524
* @since 1.1
@@ -544,8 +545,8 @@ public static void copyDirectory(final File srcDir, final File destDir) throws I
544545
* @param srcDir an existing directory to copy, must not be {@code null}.
545546
* @param destDir the new directory, must not be {@code null}.
546547
* @param preserveFileDate true if the file date of the copy should be the same as the original.
547-
* @throws NullPointerException if any of the given {@link File}s are {@code null}.
548-
* @throws IllegalArgumentException if the source or destination is invalid.
548+
* @throws IllegalArgumentException if {@code srcDir} exists but is not a directory,
549+
* the source and the destination directory are the same, or the destination is not writable
549550
* @throws FileNotFoundException if the source does not exist.
550551
* @throws IOException if an error occurs or setting the last-modified time didn't succeed.
551552
* @since 1.1
@@ -594,7 +595,8 @@ public static void copyDirectory(final File srcDir, final File destDir, final bo
594595
* @param destDir the new directory, must not be {@code null}.
595596
* @param filter the filter to apply, null means copy all directories and files should be the same as the original.
596597
* @throws NullPointerException if any of the given {@link File}s are {@code null}.
597-
* @throws IllegalArgumentException if the source or destination is invalid.
598+
* @throws IllegalArgumentException if {@code srcDir} exists but is not a directory,
599+
* the source and the destination directory are the same, or the destination is not writable
598600
* @throws FileNotFoundException if the source does not exist.
599601
* @throws IOException if an error occurs or setting the last-modified time didn't succeed.
600602
* @since 1.4
@@ -645,7 +647,8 @@ public static void copyDirectory(final File srcDir, final File destDir, final Fi
645647
* @param filter the filter to apply, null means copy all directories and files.
646648
* @param preserveFileDate true if the file date of the copy should be the same as the original.
647649
* @throws NullPointerException if any of the given {@link File}s are {@code null}.
648-
* @throws IllegalArgumentException if the source or destination is invalid.
650+
* @throws IllegalArgumentException if {@code srcDir} exists but is not a directory,
651+
* the source and the destination directory are the same, or the destination is not writable
649652
* @throws FileNotFoundException if the source does not exist.
650653
* @throws IOException if an error occurs or setting the last-modified time didn't succeed.
651654
* @since 1.4
@@ -696,7 +699,8 @@ public static void copyDirectory(final File srcDir, final File destDir, final Fi
696699
* @param preserveFileDate true if the file date of the copy should be the same as the original
697700
* @param copyOptions options specifying how the copy should be done, for example {@link StandardCopyOption}.
698701
* @throws NullPointerException if any of the given {@link File}s are {@code null}.
699-
* @throws IllegalArgumentException if the source or destination is invalid.
702+
* @throws IllegalArgumentException if {@code srcDir} exists but is not a directory,
703+
* the source and the destination directory are the same, or the destination is not writable
700704
* @throws FileNotFoundException if the source does not exist.
701705
* @throws IOException if an error occurs or setting the last-modified time didn't succeed.
702706
* @since 2.8.0
@@ -834,7 +838,7 @@ public static void copyFile(final File srcFile, final File destFile, final boole
834838
* @param copyOptions options specifying how the copy should be done, for example {@link StandardCopyOption}.
835839
* @throws NullPointerException if any of the given {@link File}s are {@code null}.
836840
* @throws FileNotFoundException if the source does not exist.
837-
* @throws IllegalArgumentException if source is not a file.
841+
* @throws IllegalArgumentException if {@code srcFile} or {@code destFile} is not a file, or {@code destFile} is not writable
838842
* @throws IOException if the output file length is not the same as the input file length after the copy completes.
839843
* @throws IOException if an I/O error occurs, or setting the last-modified time didn't succeed.
840844
* @see #copyFileToDirectory(File, File, boolean)
@@ -1334,6 +1338,7 @@ public static boolean directoryContains(final File directory, final File child)
13341338
* @param preserveDirDate preserve the directories last modified dates.
13351339
* @param copyOptions options specifying how the copy should be done, see {@link StandardCopyOption}.
13361340
* @throws IOException if the directory was not created along with all its parent directories.
1341+
* @throws IllegalArgumentException if {@code destDir} is not writable
13371342
* @throws SecurityException See {@link File#mkdirs()}.
13381343
*/
13391344
private static void doCopyDirectory(final File srcDir, final File destDir, final FileFilter fileFilter, final List<String> exclusionList,
@@ -2245,7 +2250,7 @@ private static AccumulatorPathVisitor listAccumulate(final File directory, final
22452250
* @param fileFilter Optional file filter, may be null.
22462251
* @return The files in the directory, never {@code null}.
22472252
* @throws NullPointerException if directory is {@code null}.
2248-
* @throws IllegalArgumentException if directory does not exist or is not a directory.
2253+
* @throws IllegalArgumentException if {@link directory} exists but is not a directory
22492254
* @throws IOException if an I/O error occurs.
22502255
*/
22512256
private static File[] listFiles(final File directory, final FileFilter fileFilter) throws IOException {
@@ -2366,7 +2371,7 @@ private static File mkdirs(final File directory) throws IOException {
23662371
* @param srcDir the directory to be moved.
23672372
* @param destDir the destination directory.
23682373
* @throws NullPointerException if any of the given {@link File}s are {@code null}.
2369-
* @throws IllegalArgumentException if the source or destination is invalid.
2374+
* @throws IllegalArgumentException if {@code srcDir} exists but is not a directory
23702375
* @throws FileNotFoundException if the source does not exist.
23712376
* @throws IOException if an error occurs or setting the last-modified time didn't succeed.
23722377
* @since 1.4
@@ -2434,7 +2439,7 @@ public static void moveDirectoryToDirectory(final File source, final File destDi
24342439
* @throws NullPointerException if any of the given {@link File}s are {@code null}.
24352440
* @throws FileExistsException if the destination file exists.
24362441
* @throws FileNotFoundException if the source file does not exist.
2437-
* @throws IOException if source or destination is invalid.
2442+
* @throws IllegalArgumentException if {@code srcFile} is a directory
24382443
* @throws IOException if an error occurs.
24392444
* @since 1.4
24402445
*/
@@ -2454,7 +2459,7 @@ public static void moveFile(final File srcFile, final File destFile) throws IOEx
24542459
* @throws NullPointerException if any of the given {@link File}s are {@code null}.
24552460
* @throws FileExistsException if the destination file exists.
24562461
* @throws FileNotFoundException if the source file does not exist.
2457-
* @throws IOException if source or destination is invalid.
2462+
* @throws IllegalArgumentException if {@code srcFile} is a directory
24582463
* @throws IOException if an error occurs or setting the last-modified time didn't succeed.
24592464
* @since 2.9.0
24602465
*/
@@ -2490,6 +2495,7 @@ public static void moveFile(final File srcFile, final File destFile, final CopyO
24902495
* @throws IOException if the directory was not created along with all its parent directories, if enabled.
24912496
* @throws IOException if an error occurs or setting the last-modified time didn't succeed.
24922497
* @throws SecurityException See {@link File#mkdirs()}.
2498+
* @throws IllegalArgumentException if {@code destDir} exists but is not a directory
24932499
* @since 1.4
24942500
*/
24952501
public static void moveFileToDirectory(final File srcFile, final File destDir, final boolean createDestDir) throws IOException {
@@ -2790,7 +2796,7 @@ private static void requireCanWrite(final File file, final String name) {
27902796
* @param name The parameter name to use in the exception message in case of null input or if the file is not a directory.
27912797
* @throws NullPointerException if the given {@link File} is {@code null}.
27922798
* @throws FileNotFoundException if the given {@link File} does not exist
2793-
* @throws IllegalArgumentException if the given {@link File} is not a directory
2799+
* @throws IllegalArgumentException if the given {@link File} exists but is not a directory.
27942800
*/
27952801
private static void requireDirectoryExists(final File directory, final String name) throws FileNotFoundException {
27962802
Objects.requireNonNull(directory, name);
@@ -2906,6 +2912,7 @@ public static BigInteger sizeOfAsBigInteger(final File file) {
29062912
* @param directory directory to inspect, must not be {@code null}.
29072913
* @return size of directory in bytes, 0 if directory is security restricted, a negative number when the real total
29082914
* is greater than {@link Long#MAX_VALUE}.
2915+
* @throws IllegalArgumentException if the given {@link File} exists but is not a directory
29092916
* @throws NullPointerException if the directory is {@code null}.
29102917
* @throws UncheckedIOException if an IO error occurs.
29112918
*/
@@ -2923,6 +2930,7 @@ public static long sizeOfDirectory(final File directory) {
29232930
*
29242931
* @param directory directory to inspect, must not be {@code null}.
29252932
* @return size of directory in bytes, 0 if directory is security restricted.
2933+
* @throws IllegalArgumentException if the given {@link File} exists but is not a directory
29262934
* @throws NullPointerException if the directory is {@code null}.
29272935
* @throws UncheckedIOException if an IO error occurs.
29282936
* @since 2.4

0 commit comments

Comments
 (0)