Skip to content

Commit bbb9ec5

Browse files
Treiblesschorlegselzer
authored andcommitted
Move method
1 parent c05ce0c commit bbb9ec5

2 files changed

Lines changed: 8 additions & 62 deletions

File tree

‎src/main/java/org/scijava/ops/base/DefaultOpMatchingService.java‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ private List<OpCandidate> filterMatches(final List<OpCandidate> candidates, fina
245245
final ArrayList<OpCandidate> matches = new ArrayList<>();
246246
double priority = Double.NaN;
247247
for (final OpCandidate candidate : candidates) {
248-
final double p = getPriority(candidate);
248+
final double p = OpUtils.getPriority(candidate);
249249
if (p != priority && !matches.isEmpty()) {
250250
// NB: Lower priority was reached; stop looking for any more
251251
// matches.
@@ -310,7 +310,7 @@ private List<OpCandidate> castMatches(final List<OpCandidate> candidates) {
310310
int minLevels = Integer.MAX_VALUE;
311311
double priority = Double.NaN;
312312
for (final OpCandidate candidate : candidates) {
313-
final double p = getPriority(candidate);
313+
final double p = OpUtils.getPriority(candidate);
314314
if (p != priority && !matches.isEmpty()) {
315315
// NB: Lower priority was reached; stop looking for any more
316316
// matches.
@@ -333,12 +333,6 @@ private List<OpCandidate> castMatches(final List<OpCandidate> candidates) {
333333
return matches;
334334
}
335335

336-
private double getPriority(final OpCandidate candidate) {
337-
// TODO: Think about what to do about non @Plugin-based ops...?
338-
// What if there is no annotation? How to discern a priority?
339-
return candidate.opInfo().getAnnotation().priority();
340-
}
341-
342336
/**
343337
* Find the total levels of casting needed for the candidate to match with
344338
* the reference.

‎src/main/java/org/scijava/ops/base/OpUtils.java‎

Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -95,58 +95,10 @@ public static List<MemberInstance<?>> outputs(StructInstance<?> op) {
9595
.filter(memberInstance -> memberInstance.member().isOutput()) //
9696
.collect(Collectors.toList());
9797
}
98-
99-
// /** Gets the namespace portion of the given op name. */
100-
// public static String getNamespace(final String opName) {
101-
// if (opName == null) return null;
102-
// final int dot = opName.lastIndexOf(".");
103-
// return dot < 0 ? null : opName.substring(0, dot);
104-
// }
105-
//
106-
// /** Gets the simple portion (without namespace) of the given op name. */
107-
// public static String stripNamespace(final String opName) {
108-
// if (opName == null) return null;
109-
// final int dot = opName.lastIndexOf(".");
110-
// return dot < 0 ? opName : opName.substring(dot + 1);
111-
// }
112-
//
113-
// /**
114-
// * Gets a string describing the given op request.
115-
// *
116-
// * @param name The op's name.
117-
// * @param args The op's input arguments.
118-
// * @return A string describing the op request.
119-
// */
120-
// public static String opString(final String name, final Object... args) {
121-
// final StringBuilder sb = new StringBuilder();
122-
// sb.append(name + "(\n\t\t");
123-
// boolean first = true;
124-
// for (final Object arg : args) {
125-
// if (first) first = false;
126-
// else sb.append(",\n\t\t");
127-
// if (arg == null) sb.append("null");
128-
// else if (arg instanceof Class) {
129-
// // NB: Class instance used to mark argument type.
130-
// sb.append(((Class<?>) arg).getSimpleName());
131-
// }
132-
// else sb.append(arg.getClass().getSimpleName());
133-
// }
134-
// sb.append(")");
135-
// return sb.toString();
136-
// }
137-
138-
// -- Helper methods --
139-
140-
// /** Filters a list with the given predicate, concealing boilerplate crap.
141-
// */
142-
// private static <T> List<T> filter(final List<T> list, final Predicate<T>
143-
// p) {
144-
// return list.stream().filter(p).collect(Collectors.toList());
145-
// }
146-
147-
// // TODO: Move to Context.
148-
// private static boolean isInjectable(final Class<?> type) {
149-
// return Service.class.isAssignableFrom(type) || //
150-
// Context.class.isAssignableFrom(type);
151-
// }
98+
99+
public static double getPriority(final OpCandidate candidate) {
100+
// TODO: Think about what to do about non @Plugin-based ops...?
101+
// What if there is no annotation? How to discern a priority?
102+
return candidate.opInfo().getAnnotation().priority();
103+
}
152104
}

0 commit comments

Comments
 (0)