package at.favre.tools.dice.encode;

import java.util.*;

public class EncoderHandler {

    public static final List<Encoder> ENCODERS = Collections.unmodifiableList(Arrays.asList(
            new AlphaNumericEncoder(),
            new Ascii85Encoder(),
            new Ascii94Encoder(),
            new Base16Encoder.Base16LowerCaseEncoder(),
            new Base16Encoder.Base16UpperCaseEncoder(),
            new Base32Encoder(),
            new Base64Encoder(),
            new BinaryEncoder(),
            new CEncoder(),
            new CSharpEncoder(),
            new DecimalByteEncoder(),
            new JavaByteArrayEncoder(),
            new KotlinByteArrayEncoder(),
            new NodeJsEncoder(),
            new NumericEncoder(),
            new PhpEncoder(),
            new Python3Encoder(),
            new SwiftEncoder()
    ));

    public List<Encoder> load() {
        Set<String> modes = new HashSet<>();

        for (Encoder encoder : ENCODERS) {
            for (String name : encoder.names()) {
                if (modes.contains(name)) {
                    throw new IllegalStateException(name + " is already defined in another encoder");
                }
                modes.add(name);
            }
        }

        return ENCODERS;
    }

    public Encoder findByName(String name) {
        if (name != null) {
            for (Encoder encoder : ENCODERS) {
                if (Arrays.asList(encoder.names()).contains(name)) {
                    return encoder;
                }
            }
        }
        return null;
    }

    public String returnRegistryInfo() {
        StringBuilder sb = new StringBuilder();

        for (Encoder encoder : ENCODERS) {
            for (String name : encoder.names()) {
                sb.append(name).append(", ");
            }
            sb.delete(sb.length() - 2, sb.length()).append("\n");
            sb.append("\tDescription: ").append(encoder.getDescription()).append("\n");
        }
        return sb.toString();
    }
}

@@ -1604,24 +1604,141 @@
 tryInfo() %7B%0A
+        final byte%5B%5D exampleBytes = new byte%5B%5D%7B(byte) 0xC6, 0x1A, 0x66, 0x3F, 0x3E, 0x1A, (byte) 0x8B, (byte) 0xAB%7D;%0A
         Stri
@@ -1769,24 +1769,24 @@
 gBuilder();%0A
-
 %0A        for
@@ -1809,32 +1809,60 @@
 r : ENCODERS) %7B%0A
+            sb.append(%22%5B%22);%0A
             for 
@@ -2007,32 +2007,44 @@
 ngth()).append(%22
+%5D%22).append(%22
 %5Cn%22);%0A          
@@ -2058,27 +2058,98 @@
 pend(%22%5Ct
-Description
+%22).append(encoder.getDescription()).append(%22%5Cn%22);%0A            sb.append(%22%5CtExample
 : %22).app
@@ -2156,39 +2156,43 @@
 end(encoder.
-getDescription(
+encode(exampleBytes
 )).append(%22%5C

Add examples to encoder doc