package remonsinnema.blog.fizzbuzz;

import java.util.Arrays;
import java.util.Collection;
import java.util.function.Function;


public class FizzBuzzer implements Function<Integer, String> {

  private final Function<Integer, String> replaceNumberWithStringRepresentation
      = n -> Integer.toString(n);
  private final Collection<ReplaceNumberWithFixedText> replacers = Arrays.asList(
      new ReplaceNumberWithFixedText(3, "Fizz"),
      new ReplaceNumberWithFixedText(5, "Buzz")
  );

  @Override
  public String apply(Integer n) {
    return numberReplacerFor(n).apply(n);
  }

  private Function<Integer, String> numberReplacerFor(Integer n) {
    for (ReplaceNumberWithFixedText replacer : replacers) {
      if (replacer.test(n)) {
        return replacer;
      }
    }
    return replaceNumberWithStringRepresentation;
  }

}

@@ -232,45 +232,23 @@
 ng%3E 
-replaceNumberWithStringRepresentation
+defaultReplacer
 %0A   
@@ -632,74 +632,62 @@
     
-for (ReplaceNumberWithFixedText replacer : replacers) %7B%0A      if (
+return replacers.stream()%0A        .filter(replacer -%3E 
 repl
@@ -699,18 +699,16 @@
 test(n))
- %7B
 %0A       
@@ -704,30 +704,68 @@
 n))%0A        
-return
+.map(replacer -%3E (Function%3CInteger, String%3E)
  replacer;%0A 
@@ -765,72 +765,63 @@
 acer
-;
+)
 %0A      
-%7D
+  .findFirst()
 %0A    
-%7D%0A
     
-return replaceNumberWithStringRepresentation
+.orElse(defaultReplacer)
 ;%0A  

Use stream