(Map<K, V> map)
| 161 | )); |
| 162 | // Inversion only works if values are unique: |
| 163 | public static <V, K> Map<V, K> |
| 164 | invert(Map<K, V> map) { |
| 165 | return map.entrySet().stream() |
| 166 | .collect(Collectors.toMap( |
| 167 | Map.Entry::getValue, |
| 168 | Map.Entry::getKey, |
| 169 | (v1, v2) -> { |
| 170 | throw new IllegalStateException(); |
| 171 | }, |
| 172 | LinkedHashMap::new |
| 173 | )); |
| 174 | } |
| 175 | public static final Map<String,Integer> |
| 176 | INVMAP = invert(MAP); |
| 177 | // Look up RGB value given a name: |
no test coverage detected