]> source.dussan.org Git - sonarqube.git/commitdiff
The Markdown class uses the new ChannelDispatch Builder
authorFreddy Mallet <freddy.mallet@gmail.com>
Tue, 24 May 2011 20:18:29 +0000 (22:18 +0200)
committerFreddy Mallet <freddy.mallet@gmail.com>
Tue, 24 May 2011 20:18:29 +0000 (22:18 +0200)
sonar-markdown/src/main/java/org/sonar/markdown/Markdown.java

index 9e7522cd69259f9b4f040547585c36d92a0d7b50..f727d748e6023d18e9e77ab2c49c1803f0934589 100644 (file)
  */
 package org.sonar.markdown;
 
-import org.sonar.channel.Channel;
 import org.sonar.channel.ChannelDispatcher;
 import org.sonar.channel.CodeReader;
 
-import java.util.Arrays;
-import java.util.List;
-
 /**
  * Entry point of the Markdown library
  */
@@ -34,15 +30,15 @@ public final class Markdown {
   private ChannelDispatcher<MarkdownOutput> dispatcher;
 
   private Markdown() {
-    List<Channel> markdownChannels = Arrays.<Channel>asList(
-        new HtmlUrlChannel(),
-        new HtmlEndOfLineChannel(),
-        new HtmlEmphasisChannel(),
-        new HtmlListChannel(),
-        new HtmlCodeChannel(),
-        new IdentifierAndNumberChannel(),
-        new BlackholeChannel());
-    dispatcher = new ChannelDispatcher<MarkdownOutput>(markdownChannels);
+    dispatcher = ChannelDispatcher.builder()
+      .addChannel(new HtmlUrlChannel())
+      .addChannel(new HtmlEndOfLineChannel())
+      .addChannel(new HtmlEmphasisChannel())
+      .addChannel(new HtmlListChannel())
+      .addChannel(new HtmlCodeChannel())
+      .addChannel(new IdentifierAndNumberChannel())
+      .addChannel(new BlackholeChannel())
+      .build();
   }
 
   private String convert(String input) {
@@ -51,7 +47,7 @@ public final class Markdown {
       MarkdownOutput output = new MarkdownOutput();
       dispatcher.consume(reader, output);
       return output.toString();
-      
+
     } finally {
       reader.close();
     }