#1817 add Walked iterable as Elegant Files.walk equivalent - #1899
Open
edmoffo wants to merge 1 commit into
Open
Conversation
Wrap Files.walk(path, depth) behind an Iterable<Path> primitive so callers can walk a file tree to a bounded depth without touching the Stream API directly. Directory already covers the unbounded case; this adds the depth-controlled variant requested in the issue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1817
Adds
org.cactoos.io.Walkedas the Elegant equivalent ofFiles.walk(Path, int), iterating every path under a starting directory up to a bounded depth.Directoryalready wraps the unboundedFiles.walk(Path)call, so this PR fills in the depth-controlled variant the issue asked for. Constructors mirrorDirectory:Walked(Path, int)andWalked(File, int), both delegating to a privateWalked(Scalar<Path>, int).A caller that today writes
try (Stream<Path> paths = Files.walk(start, 2)) { ... }can now writenew Walked(start, 2)and treat it as any other cactoosIterable<Path>.Locally ran
mvn -Dtest='DirectoryTest,WalkedTest' -Dhone.skip=true -Djacoco.skip=true test(4 tests pass) andmvn -Pqulice -Dhone.skip=true -Djacoco.skip=true -DskipTests verify(BUILD SUCCESS, qulice clean). Could not exercise the fullmvnmatrix here becausehone-maven-pluginrequires Docker; CI on the PR will cover the rest.