public String generateName(String name) { if (contains(name)) { String base = name; do { name = base + ++nameCounter; } while (contains(name)); } return name;
public String generateName() { return generateName(prefix);
  public String generateName(String name) {    if (contains(name)) {      String base = name;      do {        name = base + ++nameCounter;      } while (contains(name));    }    return name;  }