String uniqueName;
int count = 0;
for (int i = 0; i < categoryList.size(); i++) {
CategoryStruct category = (CategoryStruct) categoryList.get(i);
if (category.getName().startsWith(name)) {
count++;
}
}
if (count != 0) {
uniqueName = defaultCategName + count;
} else {
uniqueName = name;
}
//add to the list
categoryList.add(new CategoryStruct(uniqueName, location));
return uniqueName;
}