new HashMap<>();
if (list != null && !list.isEmpty()) {
int size = list.size();
if (size % 3 != 0) {
//wrong number of elements, not permitted
throw new BadCommandArgumentsException(
ErrorStrings.ERROR_PARSE_FAILURE + description);
}
for (int count = 0; count < size; count += 3) {
String role = list.get(count);
String key = list.get(count + 1);
String val = list.get(count + 2);
Map<String, String> roleMap = results.get(role);
if (roleMap == null) {
//demand create new role map
roleMap = new HashMap<>();
results.put(role, roleMap);
}
if (roleMap.get(key) != null) {
throw new BadCommandArgumentsException(
ErrorStrings.ERROR_DUPLICATE_ENTRY + description
+ ": for key " + key + " under " + role);
}
roleMap.put(key, val);
}