List<T> () { int[] selection = myTableView.getComponent().getSelectedRows(); if (selection.length == 0 || myElements.isEmpty()) { return Collections.emptyList(); } else { List<T> result = new ArrayList<>(selection.length); for (int row : selection) { result.add(myElements.get(row)); } return result; } }