|
5 | 5 | import java.lang.reflect.Field; |
6 | 6 | import java.lang.reflect.InvocationTargetException; |
7 | 7 | import java.lang.reflect.Method; |
| 8 | +import java.util.Optional; |
8 | 9 | import java.util.ServiceLoader; |
9 | 10 |
|
10 | 11 | import org.scijava.Context; |
11 | 12 | import org.scijava.Priority; |
12 | | -import org.scijava.discovery.therapi.TherapiDiscoverer; |
13 | 13 | import org.scijava.discovery.therapi.TaggedElement; |
| 14 | +import org.scijava.discovery.therapi.TherapiDiscoverer; |
14 | 15 | import org.scijava.ops.api.OpInfo; |
15 | 16 | import org.scijava.ops.api.OpUtils; |
16 | 17 | import org.scijava.ops.engine.hint.DefaultHints; |
|
34 | 35 | * |
35 | 36 | * @author Gabriel Selzer |
36 | 37 | */ |
37 | | -public class TagBasedOpInfoDiscoverer extends TherapiDiscoverer { |
| 38 | +public class TherapiOpInfoDiscoverer extends TherapiDiscoverer { |
38 | 39 |
|
39 | 40 | private static final String TAGTYPE = "op"; |
40 | 41 |
|
41 | | - public TagBasedOpInfoDiscoverer() { |
42 | | - super(ServiceLoader.load(Parser.class).findFirst().get()); |
| 42 | + public TherapiOpInfoDiscoverer() { |
| 43 | + super(serviceLoadParser()); |
| 44 | + } |
| 45 | + |
| 46 | + public static Parser serviceLoadParser() { |
| 47 | + Optional<Parser> optional = ServiceLoader.load(Parser.class).findFirst(); |
| 48 | + if (optional.isEmpty()) |
| 49 | + throw new IllegalArgumentException("Tried to create a TherapiOpInfoDiscoverer without a Parser available!" // |
| 50 | + + " Ensure a Parser implementation is provided via module!"); |
| 51 | + return optional.get(); |
43 | 52 | } |
44 | 53 |
|
45 | 54 | private OpInfo opClassGenerator(Class<?> cls, double priority, String[] names) { |
|
0 commit comments