3636
3737import org .scijava .ops .api .InfoTree ;
3838import org .scijava .ops .api .OpInfo ;
39+ import org .scijava .priority .Prioritized ;
40+ import org .scijava .priority .Priority ;
3941
40- public interface InfoTreeGenerator {
42+ public interface InfoTreeGenerator extends Prioritized < InfoTreeGenerator > {
4143
4244
4345 /**
@@ -68,13 +70,11 @@ static InfoTreeGenerator findSuitableGenerator(String signature,
6870 {
6971 List <InfoTreeGenerator > suitableGenerators = generators .stream () //
7072 .filter (g -> g .canGenerate (signature )) //
73+ .sorted () //
7174 .collect (Collectors .toList ());
72- if (suitableGenerators .size () == 0 ) throw new IllegalArgumentException (
75+ if (suitableGenerators .isEmpty () ) throw new IllegalArgumentException (
7376 "No InfoTreeGenerator in given collection " + generators +
7477 " is able to reify signature " + signature );
75- if (suitableGenerators .size () > 1 ) throw new IllegalArgumentException (
76- "Signature " + signature +
77- " is able to be reified by multiple generators: " + suitableGenerators );
7878 return suitableGenerators .get (0 );
7979 }
8080
@@ -90,8 +90,8 @@ static InfoTree generateDependencyTree(String subsignature,
9090 * Finds the subsignature in {@link String} {@code signature}. The
9191 * subsignature is assumed to start at index {@code start}.
9292 *
93- * @param signature
94- * @param start
93+ * @param signature the signature containing a subsignature
94+ * @param start the index where the subsignature starts
9595 * @return a signature contained withing {@code signature}
9696 */
9797 static String subSignatureFrom (String signature , int start ) {
@@ -103,8 +103,7 @@ static String subSignatureFrom(String signature, int start) {
103103 else if (ch == InfoTree .DEP_END_DELIM ) {
104104 depth --;
105105 if (depth == 0 ) {
106- int depsEnd = i ;
107- return signature .substring (start , depsEnd + 1 );
106+ return signature .substring (start , i + 1 );
108107 }
109108 }
110109 }
@@ -124,4 +123,8 @@ else if (ch == InfoTree.DEP_END_DELIM) {
124123 */
125124 boolean canGenerate (String signature );
126125
126+ @ Override
127+ default double getPriority () {
128+ return Priority .NORMAL ;
129+ }
127130}
0 commit comments