문제

Is this by design ?

Map<String, Map<String, String>> rowMap = treeTable.rowMap();
Map<String, String> notSortedTreeRow = rowMap.get(rowId);

so that you can have rowMap sorted (as SortedMap) but you can't have sorted notSortedTreeRow (TreeRow) which is [column, value] ?

EDIT: It was my fault, I had a String representation of Integers and I was on the impression that numerical Strings were compared based on the numerical value :-)

Something like this if I oversimplify it:

TreeBasedTable<String, String, String> table = TreeBasedTable.create();

table.put("1", "8", "x");
table.put("1", "9", "x");
table.put("1", "10", "x");

Map<String,String> map = table.rowMap().get("1");
도움이 되었습니까?

해결책

Just do:

SortedMap<String, String> sortedRow = (SortedMap<String, String>) rowMap.get(rowId);

as it is TreeRow object instance, which is SortedMap. It is guarateed by RowSortedTable interface, and it does not override Table's rowMap argument, because it is not possible in Java.

EDIT:

Answering original question here:

Is this by design?

Yes, it's by Java's design.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top