ctubbsii commented on code in PR #3154:
URL: https://github.com/apache/accumulo/pull/3154#discussion_r1063693631
##########
core/src/main/java/org/apache/accumulo/core/file/FilePrefix.java:
##########
@@ -29,18 +31,8 @@ public enum FilePrefix {
}
public static FilePrefix fromPrefix(String prefix) {
- switch (prefix) {
- case "I":
- return BULK_IMPORT;
- case "F":
- return MINOR_COMPACTION;
- case "C":
- return MAJOR_COMPACTION;
- case "A":
- return MAJOR_COMPACTION_ALL_FILES;
- default:
- throw new IllegalArgumentException("Unknown prefix type: " + prefix);
- }
+ return Stream.of(FilePrefix.values()).filter(p ->
p.prefix.equals(prefix)).findAny()
+ .orElseThrow(() -> new IllegalArgumentException("Unknown prefix type:
" + prefix));
Review Comment:
When I proposed this on #3148, I did not test it. The FilePrefix class
should have a unit test that verifies this works correctly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]