|
35 | 35 | import java.util.*; |
36 | 36 | import java.util.function.BiConsumer; |
37 | 37 | import java.util.stream.Collectors; |
| 38 | +import java.util.stream.StreamSupport; |
38 | 39 |
|
39 | 40 | import org.scijava.discovery.Discoverer; |
40 | 41 | import org.scijava.discovery.ManualDiscoverer; |
@@ -325,6 +326,35 @@ public Collection<OpInfo> infosFrom(Object o) { |
325 | 326 | .collect(Collectors.toSet()); |
326 | 327 | } |
327 | 328 |
|
| 329 | + @Override |
| 330 | + public Collection<String> descriptions() { |
| 331 | + return descriptions(infos()); |
| 332 | + } |
| 333 | + |
| 334 | + @Override |
| 335 | + public Collection<String> descriptions(String name) { |
| 336 | + return descriptions(infos(name)); |
| 337 | + } |
| 338 | + |
| 339 | + /** |
| 340 | + * Helper method to get the descriptions for each {@link OpInfo} in |
| 341 | + * {@code infos} |
| 342 | + * <p> |
| 343 | + * NB we return a {@link List} here to preserve multiple instances of the same |
| 344 | + * {@link OpInfo}. This is consistent with {@link DefaultOpEnvironment#infos} |
| 345 | + * returning multiple instances of the same {@link OpInfo}. The duplicate |
| 346 | + * {@link OpInfo}s are created when Ops have multiple names. |
| 347 | + * |
| 348 | + * @param infos |
| 349 | + * @return a set of {@link String}s, one describing each {@link OpInfo} in |
| 350 | + * {@code infos}. |
| 351 | + */ |
| 352 | + private List<String> descriptions(Iterable<OpInfo> infos) { |
| 353 | + return StreamSupport.stream(infos.spliterator(), true) // |
| 354 | + .map(OpInfo::toString) // |
| 355 | + .collect(Collectors.toList()); |
| 356 | + } |
| 357 | + |
328 | 358 | @SuppressWarnings("unchecked") |
329 | 359 | private <T> RichOp<T> findOp(final String opName, final Nil<T> specialType, |
330 | 360 | final Nil<?>[] inTypes, final Nil<?> outType, Hints hints) |
|
0 commit comments