|
6 | 6 | import java.util.List; |
7 | 7 | import java.util.Map; |
8 | 8 | import java.util.Optional; |
9 | | -import java.util.stream.Collectors; |
10 | | -import java.util.stream.Stream; |
11 | 9 |
|
12 | 10 | // To add a new AcquisitionMode: |
13 | 11 | // 1) Add a new constant to the enum. |
@@ -63,9 +61,6 @@ public enum AcquisitionMode { |
63 | 61 | // Display text used in the UI |
64 | 62 | private final String text_; |
65 | 63 |
|
66 | | - private static final Map<String, AcquisitionMode> STRING_TO_ENUM = |
67 | | - Stream.of(values()).collect(Collectors.toMap(Object::toString, e -> e)); |
68 | | - |
69 | 64 | AcquisitionMode(final String text) { |
70 | 65 | text_ = text; |
71 | 66 | } |
@@ -94,39 +89,13 @@ public boolean isStageScanMode() { |
94 | 89 | * @param hasStageScanning {@code true} if stage scan hardware is available |
95 | 90 | * @return a {@code List} of {@link AcquisitionMode} constants |
96 | 91 | */ |
97 | | - public static List<AcquisitionMode> getValidModes(final GeometryType geometry, final boolean hasStageScanning) { |
| 92 | + public static AcquisitionMode[] getValidModes(final GeometryType geometry, final boolean hasStageScanning) { |
98 | 93 | return Optional.ofNullable(geometry) |
99 | | - .map(MODES_BY_GEOMETRY::get) // returns null if geometry is not in map |
100 | | - .orElse(Collections.emptyList()) |
101 | | - .stream() |
102 | | - .filter(mode -> hasStageScanning || !mode.isStageScanMode()) |
103 | | - .collect(Collectors.toList()); |
104 | | - } |
105 | | - |
106 | | - /** |
107 | | - * Return an array of {@code String} labels for a dropdown menu. |
108 | | - * |
109 | | - * @param geometry the microscope {@link GeometryType} |
110 | | - * @param hasStageScanning {@code true} if stage scan hardware is available |
111 | | - * @return an array of strings |
112 | | - */ |
113 | | - public static String[] getLabels(final GeometryType geometry, final boolean hasStageScanning) { |
114 | | - return getValidModes(geometry, hasStageScanning).stream() |
115 | | - .map(AcquisitionMode::toString) |
116 | | - .toArray(String[]::new); |
| 94 | + .map(MODES_BY_GEOMETRY::get) // returns null if geometry is not in map |
| 95 | + .orElse(Collections.emptyList()) |
| 96 | + .stream() |
| 97 | + .filter(mode -> hasStageScanning || !mode.isStageScanMode()) |
| 98 | + .toArray(AcquisitionMode[]::new); |
117 | 99 | } |
118 | 100 |
|
119 | | - /** |
120 | | - * Returns the {@link AcquisitionMode} associated with the string label. |
121 | | - * <p> |
122 | | - * If the provided string is {@code null} or does not match any known |
123 | | - * acquisition mode, an empty {@link Optional} is returned. |
124 | | - * |
125 | | - * @param str the string label to convert (Example: "Stage scan") |
126 | | - * @return an {@link Optional} containing the matching {@link AcquisitionMode}, |
127 | | - * or an empty {@code Optional} if no match is found. |
128 | | - */ |
129 | | - public static Optional<AcquisitionMode> fromString(final String str) { |
130 | | - return Optional.ofNullable(str).map(STRING_TO_ENUM::get); |
131 | | - } |
132 | 101 | } |
0 commit comments