是否有相当于从位图中获取所有键(或反转)的东西,并将每个特殊字符作为一个全新的字符串连接(不迭代地图并手动构建它?
private static final BiMap<String, String> stuff = HashBiMap.create();
static {
stuff.put("S1", "STUFF_TYPE_1");
stuff.put("S2", "STUFF_TYPE_2");
stuff.put("S3", "STUFF_TYPE_3");
}
// The non-terminal <> is what I'm asking if something like exists either with bimap or some other container?
private static final String concateKeys = <stuff.getAllKeys().assignDelimiter("|").toString();>
然后concateKeys的值=“S1 | S2 | S3”
答案 0 :(得分:1)
也许你想看一下Google Guava library的Joiner
类。
答案 1 :(得分:1)
假设这是一个番石榴BiMap
,这只是
Joiner.on('|').join(stuff.keySet());