protected Path convertToRelative(final Path path) { if (path != null) { final RelativePathService service = property().service(RelativePathService.class); if (service == null) { if (enclosed()) { for (Path root : getBasePaths()) { if (root.isPrefixOf(path)) { return path.makeRelativeTo(root); } } } else { final String pathDevice = path.getDevice(); for (Path root : getBasePaths()) { if (MiscUtil.equal(pathDevice, root.getDevice())) { return path.makeRelativeTo(root); } } } } else { return service.convertToRelative(path); } } return null; }