entry.getKey().getName(), entry.getValue());
}
for (Map.Entry<String, List<JEnumConstant>> entry : map.entrySet()) {
String listExpr;
if (entry.getValue().size() == 1) {
JEnumConstant e = entry.getValue().get(0);
// Collections.singletonList(Enum.FOO)
listExpr = String.format("%s.<%s<?>> singletonList(%s.%s)",
Collections.class.getCanonicalName(),
Enum.class.getCanonicalName(),
e.getEnclosingType().getQualifiedSourceName(), e.getName());
} else {
// Arrays.asList(Enum.FOO, OtherEnum.FOO, ThirdEnum,FOO)
StringBuilder sb = new StringBuilder();
boolean needsComma = false;
sb.append(String.format("%s.<%s<?>> asList(",
Arrays.class.getCanonicalName(), Enum.class.getCanonicalName()));
for (JEnumConstant e : entry.getValue()) {
if (needsComma) {
sb.append(",");
}
needsComma = true;
sb.append(e.getEnclosingType().getQualifiedSourceName()).append(".").append(
e.getName());
}
sb.append(")");
listExpr = sb.toString();
}
sw.println("stringsToEnumsMap.put(\"%s\", %s);", entry.getKey(), listExpr);