imagej / imagej/imagej-ops

Expand Contingent API to allow a reason

Open
#458 3 comments 0 reactions 1 assignee Claimed by @ctrueden View on GitHub
Dominant language
Java
Stars
94
Forks
44
PR merge metrics
No merged PRs in 30d

Description

When ops do not conform due to the `conforms()` method of `Contingent` returning `false`, there is currently no way to express _why_ the contingency fails. We should expand the contract somehow to provide this. Options which occur to me:
- Throw unchecked `IllegalArgumentException` in `conforms()` in cases where the inputs do not conform. This makes the `boolean` return type moot, so we could additionally change the method signature to `void checkInputs()` or something like that. Obviously, that would be a breaking change, but better now than later.
- Same as previous, but throw a checked `ContingencyException` instead.
- Add a `String getNonConformanceReason()` method or similar to `Contingent`, with default implementation returning `null` or empty string.
- Use SJC's [Cancelable](https://github.com/scijava/scijava-common/blob/scijava-common-2.60.2/src/main/java/org/scijava/Cancelable.java) interface. Ops that implement `Cancelable` in addition to `Contingent` can flag themselves as canceled during the `conforms()` code, which will let them provide a cancelation reason.

@dietzc, @kephale and others: Do you have a design preference here? I am leaning toward `Cancelable`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.