Skip to content

Commit

Permalink
AbstractInputHarvester: make getObjects() not return duplicates
Browse files Browse the repository at this point in the history
* both the convertService and the objectService attach objects of a
given type to the result list of AbstractInputHarvester:getObjects
* this results into the same objects being in the list twice
* using a set avoids duplicates in the list
  • Loading branch information
frauzufall committed May 28, 2020
1 parent dcb568d commit ca7bf72
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/org/scijava/widget/AbstractInputHarvester.java
Expand Up @@ -30,7 +30,9 @@
package org.scijava.widget;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.scijava.AbstractContextual;
import org.scijava.convert.ConvertService;
Expand Down Expand Up @@ -129,10 +131,10 @@ private <T> WidgetModel addInput(final InputPanel<P, W> inputPanel,
@SuppressWarnings("unchecked")
private List<?> getObjects(final Class<?> type) {
@SuppressWarnings("rawtypes")
List compatibleInputs =
new ArrayList(convertService.getCompatibleInputs(type));
Set compatibleInputs =
new HashSet(convertService.getCompatibleInputs(type));
compatibleInputs.addAll(objectService.getObjects(type));
return compatibleInputs;
return new ArrayList<>(compatibleInputs);
}

}

0 comments on commit ca7bf72

Please sign in to comment.