initialize() fails when the current op's in() or out() is null
- Dominant language
- Java
- Stars
- 94
- Forks
- 44
- PR merge metrics
- No merged PRs in 30d
Description
If an op is matched with class objects, then its in() and/or out() will be null. As a result, its initialize() method will not work as `null` does not contain any type information.
For example, it is ligitimate to match [CopyImg](https://github.com/imagej/imagej-ops/blob/master/src/main/java/net/imagej/ops/copy/CopyImg.java#L64) without output. The code in the link has a bug of assuming in() and out() are the same in dimensions and IterationOrder, which can be generated as follow, since internally the map op between two IterableInterval will be used:
```
ops.run(CopyImg.class, outputCellImg, inputArrImg);
```
But once you replace the first `in()` with `out()` in the highlighted line of code, the method will fail as long as you do this:
```
ops.run(CopyImg.class, someImg);
```
One way to workaround would be checking null and if out() is null, use its expected class to match. However, this will not work if `out()` is totally generic (although this case should be rare).
Do you think we should also care about the case when `in()` is null? In addition, the null check seems to make the code very unreadable, but I cannot think of another solution. @ctrueden Any idea?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.