DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
More Idiomatic TalkingPuffin
if (selectedRow != -1) {
cursorCandidates = ((selectedRow + 1) to table.getRowCount).foldLeft(Nil:List[Long]) { (res, cur) =>
model.getStatusAt(table.convertRowIndexToModel(i)).id :: candidates
}.reverse
}
// and
// find then flatMap because find would return Option[Option[Long]]
cursorCandidates.find(model.getIndexOfStatus(_).isDefined).flatMap { id =>
val viewIdx = table.convertRowIndexToView(i)
table.getSelectionModel.addSelectionInterval(viewIdx, viewIdx);
log.debug("Found cursor index from candidates: " + i)
}





