protected static TransferItem resolve(final Path remote, final Local local) {
        if(StringUtils.containsAny(remote.getName(), '*')) {
            // Treat asterisk as wildcard
            return new TransferItem(remote.getParent(), local);
        }
        if(remote.isDirectory()) {
            // Remote path resolves to directory
            if(local.exists()) {
                return new TransferItem(remote, LocalFactory.get(local, remote.getName()));
            }
            return new TransferItem(remote, local);
        }
        // Remote path resolves to file
        if(local.isDirectory()) {
            // Append remote filename to local target
            return new TransferItem(remote, LocalFactory.get(local, remote.getName()));
        }
        // Keep from input
        return new TransferItem(remote, local);
    }
@Test
    public void testResolveFileToFile() {
        final Local temp = new FlatTemporaryFileService().create(new AlphanumericRandomStringService().random());
        final Path file = new Path("/f", EnumSet.of(Path.Type.file));
        final TransferItem item = DownloadTransferItemFinder.resolve(file, temp);
        assertEquals(file, item.remote);
        assertEquals(temp, item.local);
    }