是否有相当于从位图中获取所有键(或逆)并将每个键与特殊字符连接为全新字符串(无需迭代映射并手动构建它?
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"
最佳答案
假设这是一个 Guava BiMap
,这只是
Joiner.on('|').join(stuff.keySet());
关于java - BiMap单个函数将值转换为连接的字符串值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21277221/