ContainerUtil.notNullize for Set

This commit is contained in:
Kirill Likhodedov
2014-09-09 15:04:17 +04:00
parent 534ac36d35
commit da53ded13d
4 changed files with 11 additions and 3 deletions
@@ -103,6 +103,7 @@ public class CollectionListModel<T> extends AbstractListModel implements Editabl
Collections.sort(myItems, comparator);
}
@NotNull
public List<T> getItems() {
return Collections.unmodifiableList(myItems);
}
@@ -2274,9 +2274,15 @@ public class ContainerUtil extends ContainerUtilRt {
@NotNull
@Contract(pure=true)
public static <T, C extends Collection<T>> C notNullize(@Nullable C collection) {
public static <T> List<T> notNullize(@Nullable List<T> list) {
return list == null ? ContainerUtilRt.<T>emptyList() : list;
}
@NotNull
@Contract(pure=true)
public static <T> Set<T> notNullize(@Nullable Set<T> set) {
//noinspection unchecked
return collection == null ? (C)ContainerUtilRt.emptyList() : collection;
return set == null ? Collections.<T>emptySet() : set;
}
@Nullable
@@ -126,6 +126,7 @@ public class VcsStructureChooser extends DialogWrapper {
return myModulesSet;
}
@NotNull
public Collection<VirtualFile> getSelectedFiles() {
return ((CollectionListModel) mySelectedList.getModel()).getItems();
}
@@ -101,7 +101,7 @@ class StructureFilterPopupComponent extends FilterPopupComponent<VcsLogStructure
new ArrayList<VirtualFile>(myRoots));
if (chooser.showAndGet()) {
myFiles.clear();
myFiles.addAll(ContainerUtil.notNullize(chooser.getSelectedFiles()));
myFiles.addAll(chooser.getSelectedFiles());
setValue(myFiles);
applyFilters();
}