This is an automated email from the ASF dual-hosted git repository. dlmarion pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push: new 4b5e7f28ad Modify FilePrefix.fromPrefix to be more dynamic (#3154) 4b5e7f28ad is described below commit 4b5e7f28ad82c0432f78526d68d4cca4b6b93275 Author: Dave Marion <dlmar...@apache.org> AuthorDate: Fri Jan 6 13:35:48 2023 -0500 Modify FilePrefix.fromPrefix to be more dynamic (#3154) --- .../java/org/apache/accumulo/core/file/FilePrefix.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/file/FilePrefix.java b/core/src/main/java/org/apache/accumulo/core/file/FilePrefix.java index 5f42877859..febec86ae4 100644 --- a/core/src/main/java/org/apache/accumulo/core/file/FilePrefix.java +++ b/core/src/main/java/org/apache/accumulo/core/file/FilePrefix.java @@ -18,6 +18,8 @@ */ package org.apache.accumulo.core.file; +import java.util.stream.Stream; + public enum FilePrefix { BULK_IMPORT("I"), MINOR_COMPACTION("F"), MAJOR_COMPACTION("C"), MAJOR_COMPACTION_ALL_FILES("A"); @@ -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)); } public String toPrefix() {