* {@ink Class#equals(Object)} rather than {@code instanceof}.
*/
List<AlignCalcWorkerI> getWorkersOfClass(Class<? extends AlignCalcWorkerI> cls);
-
+
+ /**
+ * Returns the list of all workers for the given name or an empty list
+ * if there are none.
+ */
+ List<AlignCalcWorkerI> getWorkersForName(String name);
+
/**
* Removes the worker from the scheduler. It does not cancel workers
* already scheduled for execution.
default void removeWorkersForAnnotation(AlignmentAnnotation annot) {
removeWorkerForAnnotation(annot);
}
-
+
+ /**
+ * Removes all workers with matching name.
+ */
+ void removeWorkersForName(String name);
+
/**
* Removes all workers of a given class. The classes are compared using
* {@link Class#equals(Object)}.
}
@Override
+ public List<AlignCalcWorkerI> getWorkersForName(String name)
+ {
+ List<AlignCalcWorkerI> collected = new ArrayList<>();
+ for (var worker : getWorkers())
+ {
+ if (worker.getCalcName().equals(name))
+ {
+ collected.add(worker);
+ }
+ }
+ return collected;
+ }
+
+ @Override
public void removeWorker(AlignCalcWorkerI worker)
{
if (worker.isDeletable())
}
@Override
+ public void removeWorkersForName(String name)
+ {
+ synchronized (registered)
+ {
+ for (var worker : getWorkers())
+ {
+ if (worker.getCalcName().equals(name))
+ {
+ removeWorker(worker);
+ }
+ }
+ }
+ }
+
+ @Override
public void disableWorker(AlignCalcWorkerI worker)
{
// Null pointer check might be needed