0

Is there something equivalent to get all keys (or inverses) from a bit map and concat each with a special character as a completely new string (without iterating through the map and building it manually?

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();>

Then the Value for concateKeys = "S1|S2|S3"

genxgeek
  • 13,109
  • 38
  • 135
  • 217

2 Answers2

1

Maybe you want to take a look at the Joiner class of the Google Guava library.

MrD
  • 1,255
  • 1
  • 10
  • 24
1

Assuming this is a Guava BiMap, this is just

Joiner.on('|').join(stuff.keySet());
Louis Wasserman
  • 191,574
  • 25
  • 345
  • 413