I have a map with strings, I want to transform it to a list of strings with \" \" as a key value separator. Is it possible using google collections?
Code example that I
Functional programming is cool, but in Java often adds complexity you really shouldn't be adding (as Java doesn't support it very well) I would suggest you use a simple loop which is much shorter, more efficient and eaiser to maintain and doesn't require an additional library to learn.
public static List mapToList(Map env) {
List result = new ArrayList();
for (Entry entry : env.entrySet())
result.add(entry.getKey() + " " + entry.getValue());
return result;
}
A simple test of code complexity it to count the number of symbols used. i.e. < ( , { = : . + @ Not counting close brackets.
plain loop 22 symbols.
functional approach 30 symbols.