@Test void testGenerateUniqueLabelRecursive() { Set<String> existingLabels = newHashSet("labelA", "labelB", "labelB (Copy)", "labelC"); String result = LabelGenerator.generateUniqueLabel("labelB", existingLabels); assertEquals("labelB (Copy) (Copy)", result); }
static String generateUniqueLabel(String label, Set<String> existingLabels) { StringBuilder newLabel = new StringBuilder(label); while (existingLabels.contains(newLabel.toString())) { newLabel.append(POSTFIX); } return newLabel.toString(); }
LabelGenerator { static String generateUniqueLabel(String label, Set<String> existingLabels) { StringBuilder newLabel = new StringBuilder(label); while (existingLabels.contains(newLabel.toString())) { newLabel.append(POSTFIX); } return newLabel.toString(); } }
LabelGenerator { static String generateUniqueLabel(String label, Set<String> existingLabels) { StringBuilder newLabel = new StringBuilder(label); while (existingLabels.contains(newLabel.toString())) { newLabel.append(POSTFIX); } return newLabel.toString(); } private  LabelGenerator(); }
LabelGenerator { static String generateUniqueLabel(String label, Set<String> existingLabels) { StringBuilder newLabel = new StringBuilder(label); while (existingLabels.contains(newLabel.toString())) { newLabel.append(POSTFIX); } return newLabel.toString(); } private  LabelGenerator();  }
LabelGenerator { static String generateUniqueLabel(String label, Set<String> existingLabels) { StringBuilder newLabel = new StringBuilder(label); while (existingLabels.contains(newLabel.toString())) { newLabel.append(POSTFIX); } return newLabel.toString(); } private  LabelGenerator();   }