This commit is contained in:
Looly 2024-11-04 18:12:36 +08:00
parent 96ad2ed57f
commit 00fac9d39a
3 changed files with 6 additions and 6 deletions

View File

@ -70,12 +70,12 @@ public class PathMover {
*/ */
public PathMover(final Path src, final Path target, final CopyOption[] options) { public PathMover(final Path src, final Path target, final CopyOption[] options) {
Assert.notNull(target, "Src path must be not null !"); Assert.notNull(target, "Src path must be not null !");
if(!PathUtil.exists(src, false)){ if (!PathUtil.exists(src, false)) {
throw new IllegalArgumentException("Src path is not exist!"); throw new IllegalArgumentException("Src path is not exist!");
} }
this.src = src; this.src = src;
this.target = Assert.notNull(target, "Target path must be not null !"); this.target = Assert.notNull(target, "Target path must be not null !");
this.options = ObjUtil.defaultIfNull(options, new CopyOption[]{}); this.options = ObjUtil.defaultIfNull(options, () -> new CopyOption[]{});
} }
/** /**
@ -94,13 +94,13 @@ public class PathMover {
* @return 目标文件Path * @return 目标文件Path
* @throws IllegalArgumentException src为目录target为其子目录抛出此异常 * @throws IllegalArgumentException src为目录target为其子目录抛出此异常
*/ */
public Path move() throws IllegalArgumentException{ public Path move() throws IllegalArgumentException {
final Path src = this.src; final Path src = this.src;
Path target = this.target; Path target = this.target;
final CopyOption[] options = this.options; final CopyOption[] options = this.options;
if (PathUtil.isSub(src, target)) { if (PathUtil.isSub(src, target)) {
if(PathUtil.equals(src, target)){ if (PathUtil.equals(src, target)) {
// issue#2845当用户传入目标路径与源路径一致时直接返回否则会导致删除风险 // issue#2845当用户传入目标路径与源路径一致时直接返回否则会导致删除风险
return target; return target;
} }

View File

@ -77,7 +77,7 @@ public class UrlPath {
* @return 节点列表 * @return 节点列表
*/ */
public List<CharSequence> getSegments() { public List<CharSequence> getSegments() {
return ObjUtil.defaultIfNull(this.segments, ListUtil.empty()); return ObjUtil.defaultIfNull(this.segments, ListUtil::empty);
} }
/** /**

View File

@ -406,7 +406,7 @@ public class TypeUtil {
if (null == field) { if (null == field) {
return null; return null;
} }
return getActualType(ObjUtil.defaultIfNull(type, field.getDeclaringClass()), field.getGenericType()); return getActualType(ObjUtil.defaultIfNull(type, field::getDeclaringClass), field.getGenericType());
} }
/** /**