public static Optional<SnapshotPath> parse(Path path) {
        Path filename = path.getFileName();
        if (filename == null) {
            return Optional.empty();
        }

        String name = filename.toString();

        boolean partial = false;
        boolean deleted = false;
        if (name.endsWith(PARTIAL_SUFFIX)) {
            partial = true;
        } else if (name.endsWith(DELETE_SUFFIX)) {
            deleted = true;
        } else if (!name.endsWith(SUFFIX)) {
            return Optional.empty();
        }

        long endOffset = Long.parseLong(name.substring(0, OFFSET_WIDTH));
        int epoch = Integer.parseInt(
            name.substring(OFFSET_WIDTH + 1, OFFSET_WIDTH + EPOCH_WIDTH + 1)
        );

        return Optional.of(new SnapshotPath(path, new OffsetAndEpoch(endOffset, epoch), partial, deleted));
    }
@Test
    public void testInvalidSnapshotFilenames() {
        Path root = FileSystems.getDefault().getPath("/");
        // Doesn't parse log files
        assertEquals(Optional.empty(), Snapshots.parse(root.resolve("00000000000000000000.log")));
        // Doesn't parse producer snapshots
        assertEquals(Optional.empty(), Snapshots.parse(root.resolve("00000000000000000000.snapshot")));
        // Doesn't parse offset indexes
        assertEquals(Optional.empty(), Snapshots.parse(root.resolve("00000000000000000000.index")));
        assertEquals(Optional.empty(), Snapshots.parse(root.resolve("00000000000000000000.timeindex")));
        // Leader epoch checkpoint
        assertEquals(Optional.empty(), Snapshots.parse(root.resolve("leader-epoch-checkpoint")));
        // partition metadata
        assertEquals(Optional.empty(), Snapshots.parse(root.resolve("partition.metadata")));
    }