| 1 16 package nl.hippo.asserts; 17 18 import java.io.File ; 19 20 public class FileAsserts extends Asserts 21 { 22 23 public static void existingDirectory(String directoryName, ExceptionFactory exceptionFactory, String identifier) 24 { 25 if (isNonExistingDirectory(new File (directoryName))) 26 { 27 throw createException(exceptionFactory, identifier + " must be an existing directory"); 28 } 29 } 30 31 public static void existingDirectory(File directory, ExceptionFactory exceptionFactory, String identifier) 32 { 33 if (isNonExistingDirectory(directory)) 34 { 35 throw createException(exceptionFactory, identifier + " must be an existing directory"); 36 } 37 } 38 39 44 public static void existingDirectory(String directoryName, RuntimeException exception) 45 { 46 existingDirectory(new File (directoryName), exception); 47 } 48 49 54 public static void existingDirectory(File directory, RuntimeException exception) 55 { 56 if (isNonExistingDirectory(directory)) 57 { 58 throw exception; 59 } 60 } 61 62 private static boolean isNonExistingDirectory(File directory) 63 { 64 return !directory.exists() || !directory.isDirectory(); 65 } 66 67 private FileAsserts() 68 { 69 super(); 70 } 71 72 } | Popular Tags |