From ca7bf72c17260f18f597775d2041b991189015f0 Mon Sep 17 00:00:00 2001 From: frauzufall Date: Thu, 28 May 2020 10:40:03 +0200 Subject: [PATCH] AbstractInputHarvester: make getObjects() not return duplicates * 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 --- .../java/org/scijava/widget/AbstractInputHarvester.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/widget/AbstractInputHarvester.java b/src/main/java/org/scijava/widget/AbstractInputHarvester.java index c17f3f6b7..582b72b77 100644 --- a/src/main/java/org/scijava/widget/AbstractInputHarvester.java +++ b/src/main/java/org/scijava/widget/AbstractInputHarvester.java @@ -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; @@ -129,10 +131,10 @@ private WidgetModel addInput(final InputPanel 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); } }