2626 * POSSIBILITY OF SUCH DAMAGE.
2727 * #L%
2828 */
29+
2930package org .scijava .ops .api ;
3031
3132/**
@@ -38,7 +39,9 @@ public final class Ops {
3839 private Ops () {}
3940
4041 /**
41- * Convenience function for determining whether {@code op} is a {@link RichOp}.
42+ * Convenience function for determining whether {@code op} is a
43+ * {@link RichOp}.
44+ *
4245 * @param op the Op
4346 * @return true iff {@code op} is a {@link RichOp}
4447 */
@@ -48,20 +51,28 @@ public static boolean isRich(Object op) {
4851
4952 /**
5053 * Convenience function for getting the {@link RichOp} of {@code op}
54+ *
5155 * @param op the Op
5256 * @return the {@link RichOp} wrapping {@code op}
5357 * @param <T> the type of {@code op}
58+ * @throws IllegalArgumentException when a {@link RichOp} cannot be obtained
59+ * for {@code op}
5460 */
5561 @ SuppressWarnings ("unchecked" )
5662 public static <T > RichOp <T > rich (T op ) {
63+ if (!isRich (op )) {
64+ throw new IllegalArgumentException (op + " is not a RichOp!" );
65+ }
5766 return (RichOp <T >) op ;
5867 }
5968
6069 /**
6170 * Convenience function for getting the {@link OpInfo} of {@code op}
71+ *
6272 * @param op the Op
6373 * @return the {@link OpInfo} that generated {@code op}
6474 * @param <T> the type of {@code op}
75+ * @throws IllegalArgumentException if {@code op} is not an Op
6576 */
6677 public static <T > OpInfo info (T op ) {
6778 return rich (op ).instance ().infoTree ().info ();
@@ -73,6 +84,7 @@ public static <T> OpInfo info(T op) {
7384 * @param op the Op
7485 * @param record true iff {@code op} should record its executions
7586 * @param <T> the type of the Op
87+ * @throws IllegalArgumentException if {@code op} is not an Op
7688 */
7789 public static <T > void recordExecutions (T op , boolean record ) {
7890 rich (op ).recordExecutions (record );
0 commit comments