我不喜欢下面的代码看起来如何,我想知道如何使用三元运算符来做到这一点:
if (isIndexed) {
Files.move(source, destination);
}
else {
Files.move(source, destination, StandardCopyOption.REPLACE_EXISTING);
}
Run Code Online (Sandbox Code Playgroud)
我期待的东西看起来像:
Files.move(source, destination, isIndexed ? xxxx : StandardCopyOption.REPLACE_EXISTING);
Run Code Online (Sandbox Code Playgroud)
如果我可以使用某种"默认"复制选项,我认为这将是我正在寻找的.但是StandardCopyOption的枚举没有"NONE"选项.
所以我可能错过了一些东西.它是什么?