private Set<Object> doFilter(Set<Object> elements) { Set<Object> result = new LinkedHashSet<Object>(); for (Object o : elements) { if (myElementClass.isInstance(o) && getFilter().isAccepted((T) o)) { result.add(o); } } return result; }
@NotNull @Override public Object[] getElementsByName( String name, boolean checkBoxState, String pattern, @NotNull ProgressIndicator canceled) { List<T> classes = myTreeClassChooserDialog.getClassesByName( name, checkBoxState, pattern, myTreeClassChooserDialog.getScope()); if (classes.size() == 0) return ArrayUtil.EMPTY_OBJECT_ARRAY; if (classes.size() == 1) { return isAccepted(classes.get(0)) ? ArrayUtil.toObjectArray(classes) : ArrayUtil.EMPTY_OBJECT_ARRAY; } Set<String> qNames = ContainerUtil.newHashSet(); List<T> list = new ArrayList<T>(classes.size()); for (T aClass : classes) { if (qNames.add(getFullName(aClass)) && isAccepted(aClass)) { list.add(aClass); } } return ArrayUtil.toObjectArray(list); }