@Test public void generateOutput_no1Match_no1To1() { OutputResult result = FuzzyPhoneNumberHelper.generateOutput(setOf(MX_A), new InputResult(setOf(MX_A, MX_A_1), Collections.singletonMap(MX_A, MX_A_1))); assertEquals(1, result.getNumbers().size()); assertTrue(result.getNumbers().containsAll(setOf(MX_A))); assertTrue(result.getRewrites().isEmpty()); }
static @NonNull OutputResult generateOutput(@NonNull Collection<String> registeredNumbers, @NonNull InputResult inputResult) { Set<String> allNumbers = new HashSet<>(registeredNumbers); Map<String, String> rewrites = new HashMap<>(); for (Map.Entry<String, String> entry : inputResult.getFuzzies().entrySet()) { if (registeredNumbers.contains(entry.getKey()) && registeredNumbers.contains(entry.getValue())) { if (mxHas1(entry.getKey())) { rewrites.put(entry.getKey(), entry.getValue()); allNumbers.remove(entry.getKey()); } else { allNumbers.remove(entry.getValue()); } } else if (registeredNumbers.contains(entry.getValue())) { rewrites.put(entry.getKey(), entry.getValue()); allNumbers.remove(entry.getKey()); } } return new OutputResult(allNumbers, rewrites); }
FuzzyPhoneNumberHelper { static @NonNull OutputResult generateOutput(@NonNull Collection<String> registeredNumbers, @NonNull InputResult inputResult) { Set<String> allNumbers = new HashSet<>(registeredNumbers); Map<String, String> rewrites = new HashMap<>(); for (Map.Entry<String, String> entry : inputResult.getFuzzies().entrySet()) { if (registeredNumbers.contains(entry.getKey()) && registeredNumbers.contains(entry.getValue())) { if (mxHas1(entry.getKey())) { rewrites.put(entry.getKey(), entry.getValue()); allNumbers.remove(entry.getKey()); } else { allNumbers.remove(entry.getValue()); } } else if (registeredNumbers.contains(entry.getValue())) { rewrites.put(entry.getKey(), entry.getValue()); allNumbers.remove(entry.getKey()); } } return new OutputResult(allNumbers, rewrites); } }
FuzzyPhoneNumberHelper { static @NonNull OutputResult generateOutput(@NonNull Collection<String> registeredNumbers, @NonNull InputResult inputResult) { Set<String> allNumbers = new HashSet<>(registeredNumbers); Map<String, String> rewrites = new HashMap<>(); for (Map.Entry<String, String> entry : inputResult.getFuzzies().entrySet()) { if (registeredNumbers.contains(entry.getKey()) && registeredNumbers.contains(entry.getValue())) { if (mxHas1(entry.getKey())) { rewrites.put(entry.getKey(), entry.getValue()); allNumbers.remove(entry.getKey()); } else { allNumbers.remove(entry.getValue()); } } else if (registeredNumbers.contains(entry.getValue())) { rewrites.put(entry.getKey(), entry.getValue()); allNumbers.remove(entry.getKey()); } } return new OutputResult(allNumbers, rewrites); }  }
FuzzyPhoneNumberHelper { static @NonNull OutputResult generateOutput(@NonNull Collection<String> registeredNumbers, @NonNull InputResult inputResult) { Set<String> allNumbers = new HashSet<>(registeredNumbers); Map<String, String> rewrites = new HashMap<>(); for (Map.Entry<String, String> entry : inputResult.getFuzzies().entrySet()) { if (registeredNumbers.contains(entry.getKey()) && registeredNumbers.contains(entry.getValue())) { if (mxHas1(entry.getKey())) { rewrites.put(entry.getKey(), entry.getValue()); allNumbers.remove(entry.getKey()); } else { allNumbers.remove(entry.getValue()); } } else if (registeredNumbers.contains(entry.getValue())) { rewrites.put(entry.getKey(), entry.getValue()); allNumbers.remove(entry.getKey()); } } return new OutputResult(allNumbers, rewrites); }   }
FuzzyPhoneNumberHelper { static @NonNull OutputResult generateOutput(@NonNull Collection<String> registeredNumbers, @NonNull InputResult inputResult) { Set<String> allNumbers = new HashSet<>(registeredNumbers); Map<String, String> rewrites = new HashMap<>(); for (Map.Entry<String, String> entry : inputResult.getFuzzies().entrySet()) { if (registeredNumbers.contains(entry.getKey()) && registeredNumbers.contains(entry.getValue())) { if (mxHas1(entry.getKey())) { rewrites.put(entry.getKey(), entry.getValue()); allNumbers.remove(entry.getKey()); } else { allNumbers.remove(entry.getValue()); } } else if (registeredNumbers.contains(entry.getValue())) { rewrites.put(entry.getKey(), entry.getValue()); allNumbers.remove(entry.getKey()); } } return new OutputResult(allNumbers, rewrites); }    }