private static File toFile( FileSystemAbstraction fs, File directory, String name, ExistingTargetStrategy existingTargetStrategy ) { File file = new File( directory, name ); if ( fs.fileExists( file ) ) { switch ( existingTargetStrategy ) { case FAIL: // Let the copy operation fail. Is this a good idea? This is how we did before this switch case case OVERWRITE: fs.deleteFile( file ); return file; case SKIP: return null; default: throw new IllegalStateException( existingTargetStrategy.name() ); } } return file; } }
private static File toFile( FileSystemAbstraction fs, File directory, String name, ExistingTargetStrategy existingTargetStrategy ) { File file = new File( directory, name ); if ( fs.fileExists( file ) ) { switch ( existingTargetStrategy ) { case FAIL: // Let the copy operation fail. Is this a good idea? This is how we did before this switch case case OVERWRITE: fs.deleteFile( file ); return file; case SKIP: return null; default: throw new IllegalStateException( existingTargetStrategy.name() ); } } return file; } }