mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
NoSuchElementException
This commit is contained in:
@@ -3834,11 +3834,11 @@ public class AbstractTreeUi {
|
||||
}
|
||||
}
|
||||
|
||||
Set<Object> toSelect = new THashSet<Object>();
|
||||
clearSelection();
|
||||
ContainerUtil.addAll(toSelect, elements);
|
||||
Set<Object> toSelect = new THashSet<Object>();
|
||||
ContainerUtil.addAllNotNull(toSelect, elements);
|
||||
if (addToSelection) {
|
||||
toSelect.addAll(currentElements);
|
||||
ContainerUtil.addAllNotNull(toSelect, currentElements);
|
||||
}
|
||||
|
||||
if (checkIfInStructure) {
|
||||
|
||||
@@ -467,6 +467,25 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all not-null elements from the {@code elements}, ignoring nulls
|
||||
*/
|
||||
public static <T> void addAllNotNull(@NotNull Collection<T> collection, @NotNull Iterable<? extends T> elements) {
|
||||
addAll(collection, elements.iterator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all not-null elements from the {@code elements}, ignoring nulls
|
||||
*/
|
||||
public static <T> void addAllNotNull(@NotNull Collection<T> collection, @NotNull Iterator<? extends T> elements) {
|
||||
while (elements.hasNext()) {
|
||||
T o = elements.next();
|
||||
if (o != null) {
|
||||
collection.add(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> List<T> collect(@NotNull Iterator<T> iterator) {
|
||||
if (!iterator.hasNext()) return Collections.emptyList();
|
||||
@@ -859,6 +878,19 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all not-null elements from the {@code elements}, ignoring nulls
|
||||
*/
|
||||
public static <T, A extends T, C extends Collection<T>> C addAllNotNull(@NotNull C collection, @NotNull A... elements) {
|
||||
//noinspection ManualArrayToCollectionCopy
|
||||
for (T element : elements) {
|
||||
if (element != null) {
|
||||
collection.add(element);
|
||||
}
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
|
||||
public static <T, U extends T> U findInstance(@NotNull Iterable<T> iterable, @NotNull Class<U> aClass) {
|
||||
return findInstance(iterable.iterator(), aClass);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user