// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
// 
//     private String serialized;
// 
//     /**
//      * Attempts to generate a String representing this markdown element.
//      *
//      * @return Markdown as String
//      * @throws MarkdownSerializationException If unable to generate a markdown String
//      */
//     public abstract String serialize() throws MarkdownSerializationException;
// 
//     /**
//      * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
//      * {@link MarkdownSerializationException} occurred.
//      *
//      * @param fallback String to return if serialization fails
//      * @return Markdown as String or specified fallback
//      */
//     public String getSerialized(String fallback) {
//         try {
//             return getSerialized();
//         } catch (MarkdownSerializationException e) {
//             return fallback;
//         }
//     }
// 
//     /**
//      * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
//      * MarkdownElement#serialized}.
//      *
//      * @return Markdown as String
//      * @throws MarkdownSerializationException If unable to generate a markdown String
//      */
//     public String getSerialized() throws MarkdownSerializationException {
//         if (serialized == null) {
//             serialized = serialize();
//         }
//         return serialized;
//     }
// 
//     public void setSerialized(String serialized) {
//         this.serialized = serialized;
//     }
// 
//     /**
//      * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
//      * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
//      */
//     public void invalidateSerialized() {
//         setSerialized(null);
//     }
// 
//     @Override
//     public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
//         return this;
//     }
// 
//     @Override
//     public String toString() {
//         return getSerialized(this.getClass().getSimpleName());
//     }
// 
// }
// 
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
// 
//     public MarkdownSerializationException() {
//         super();
//     }
// 
//     public MarkdownSerializationException(String s) {
//         super(s);
//     }
// 
//     public MarkdownSerializationException(String s, Throwable throwable) {
//         super(s, throwable);
//     }
// 
//     public MarkdownSerializationException(Throwable throwable) {
//         super(throwable);
//     }
// 
// }
// 
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
// 
//     public static String fillUpAligned(String value, String fill, int length, int alignment) {
//         switch (alignment) {
//             case Table.ALIGN_RIGHT: {
//                 return fillUpRightAligned(value, fill, length);
//             }
//             case Table.ALIGN_CENTER: {
//                 return fillUpCenterAligned(value, fill, length);
//             }
//             default: {
//                 return fillUpLeftAligned(value, fill, length);
//             }
//         }
//     }
// 
//     public static String fillUpLeftAligned(String value, String fill, int length) {
//         if (value.length() >= length) {
//             return value;
//         }
//         while (value.length() < length) {
//             value += fill;
//         }
//         return value;
//     }
// 
//     public static String fillUpRightAligned(String value, String fill, int length) {
//         if (value.length() >= length) {
//             return value;
//         }
//         while (value.length() < length) {
//             value = fill + value;
//         }
//         return value;
//     }
// 
//     public static String fillUpCenterAligned(String value, String fill, int length) {
//         if (value.length() >= length) {
//             return value;
//         }
//         boolean left = true;
//         while (value.length() < length) {
//             if (left) {
//                 value = fillUpLeftAligned(value, fill, value.length() + 1);
//             } else {
//                 value = fillUpRightAligned(value, fill, value.length() + 1);
//             }
//             left = !left;
//         }
//         return value;
//     }
// 
//     public static String surroundValueWith(String value, String surrounding) {
//         return surrounding + value + surrounding;
//     }
// 
// }


import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
package net.steppschuh.markdowngenerator.progress;


/**
 * Created by Stephan on 12/18/2016.
 */

public class ProgressBar extends MarkdownElement {

    public static final int LENGTH_SMALL = 15;
    public static final int LENGTH_NORMAL = 20;
    public static final int LENGTH_LARGE = 50;

    public static final char OPENING_CHAR_DEFAULT = '[';
    public static final char CLOSING_CHAR_DEFAULT = ']';

    public static final char FILL_CHAR_DEFAULT = '=';
    public static final char EMPTY_CHAR_DEFAULT = '-';

    private char openingChar = OPENING_CHAR_DEFAULT;
    private char closingChar = CLOSING_CHAR_DEFAULT;

    private char fillChar = FILL_CHAR_DEFAULT;
    private char emptyChar = EMPTY_CHAR_DEFAULT;

    private int length = LENGTH_NORMAL;
    private boolean appendValue = false;
    private boolean appendPercentage = false;

    private double value;
    private double minimumValue = 0;
    private double maximumValue = 1;

    public ProgressBar(double value) {
        this.value = value;
    }

    public ProgressBar(double value, int length) {
        this.value = value;
        this.length = length;
    }

    private void trimValue() {
        value = Math.max(minimumValue, Math.min(maximumValue, value));
    }

    @Override
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
// 
//     private String serialized;
// 
//     /**
//      * Attempts to generate a String representing this markdown element.
//      *
//      * @return Markdown as String
//      * @throws MarkdownSerializationException If unable to generate a markdown String
//      */
//     public abstract String serialize() throws MarkdownSerializationException;
// 
//     /**
//      * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
//      * {@link MarkdownSerializationException} occurred.
//      *
//      * @param fallback String to return if serialization fails
//      * @return Markdown as String or specified fallback
//      */
//     public String getSerialized(String fallback) {
//         try {
//             return getSerialized();
//         } catch (MarkdownSerializationException e) {
//             return fallback;
//         }
//     }
// 
//     /**
//      * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
//      * MarkdownElement#serialized}.
//      *
//      * @return Markdown as String
//      * @throws MarkdownSerializationException If unable to generate a markdown String
//      */
//     public String getSerialized() throws MarkdownSerializationException {
//         if (serialized == null) {
//             serialized = serialize();
//         }
//         return serialized;
//     }
// 
//     public void setSerialized(String serialized) {
//         this.serialized = serialized;
//     }
// 
//     /**
//      * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
//      * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
//      */
//     public void invalidateSerialized() {
//         setSerialized(null);
//     }
// 
//     @Override
//     public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
//         return this;
//     }
// 
//     @Override
//     public String toString() {
//         return getSerialized(this.getClass().getSimpleName());
//     }
// 
// }
// 
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
// 
//     public MarkdownSerializationException() {
//         super();
//     }
// 
//     public MarkdownSerializationException(String s) {
//         super(s);
//     }
// 
//     public MarkdownSerializationException(String s, Throwable throwable) {
//         super(s, throwable);
//     }
// 
//     public MarkdownSerializationException(Throwable throwable) {
//         super(throwable);
//     }
// 
// }
// 
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
// 
//     public static String fillUpAligned(String value, String fill, int length, int alignment) {
//         switch (alignment) {
//             case Table.ALIGN_RIGHT: {
//                 return fillUpRightAligned(value, fill, length);
//             }
//             case Table.ALIGN_CENTER: {
//                 return fillUpCenterAligned(value, fill, length);
//             }
//             default: {
//                 return fillUpLeftAligned(value, fill, length);
//             }
//         }
//     }
// 
//     public static String fillUpLeftAligned(String value, String fill, int length) {
//         if (value.length() >= length) {
//             return value;
//         }
//         while (value.length() < length) {
//             value += fill;
//         }
//         return value;
//     }
// 
//     public static String fillUpRightAligned(String value, String fill, int length) {
//         if (value.length() >= length) {
//             return value;
//         }
//         while (value.length() < length) {
//             value = fill + value;
//         }
//         return value;
//     }
// 
//     public static String fillUpCenterAligned(String value, String fill, int length) {
//         if (value.length() >= length) {
//             return value;
//         }
//         boolean left = true;
//         while (value.length() < length) {
//             if (left) {
//                 value = fillUpLeftAligned(value, fill, value.length() + 1);
//             } else {
//                 value = fillUpRightAligned(value, fill, value.length() + 1);
//             }
//             left = !left;
//         }
//         return value;
//     }
// 
//     public static String surroundValueWith(String value, String surrounding) {
//         return surrounding + value + surrounding;
//     }
// 
// }


// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/progress/ProgressBar.java
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;

package net.steppschuh.markdowngenerator.progress;


/**
 * Created by Stephan on 12/18/2016.
 */

public class ProgressBar extends MarkdownElement {

    public static final int LENGTH_SMALL = 15;
    public static final int LENGTH_NORMAL = 20;
    public static final int LENGTH_LARGE = 50;

    public static final char OPENING_CHAR_DEFAULT = '[';
    public static final char CLOSING_CHAR_DEFAULT = ']';

    public static final char FILL_CHAR_DEFAULT = '=';
    public static final char EMPTY_CHAR_DEFAULT = '-';

    private char openingChar = OPENING_CHAR_DEFAULT;
    private char closingChar = CLOSING_CHAR_DEFAULT;

    private char fillChar = FILL_CHAR_DEFAULT;
    private char emptyChar = EMPTY_CHAR_DEFAULT;

    private int length = LENGTH_NORMAL;
    private boolean appendValue = false;
    private boolean appendPercentage = false;

    private double value;
    private double minimumValue = 0;
    private double maximumValue = 1;

    public ProgressBar(double value) {
        this.value = value;
    }

    public ProgressBar(double value, int length) {
        this.value = value;
        this.length = length;
    }

    private void trimValue() {
        value = Math.max(minimumValue, Math.min(maximumValue, value));
    }

    @Override
    public String serialize() throws MarkdownSerializationException {