in async/src/main/java/org/apache/geode_examples/async/ExampleAsyncEventListener.java [35:50]
public String spellCheck(String candidate) {
int index = -1;
int shortest = Integer.MAX_VALUE;
for (int i = 0; i < words.length; ++i) {
final String word = words[i];
final int score = distance.calculate(word, candidate);
if (score < shortest) {
index = i;
shortest = score;
}
}
if (0 <= index) {
return words[index];
}
return candidate;
}