// Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
//     // Object
//     public static final int NULL = 1;
//     public static final int EQUAL = 2;
// 
//     // Boolean
//     public static final int FALSE = 4;
//     public static final int TRUE = 8;
// 
//     // String
//     public static final int EMPTY = 16;
// 
//     // Integer
//     public static final int GREATER = 32;
//     public static final int LOWER = 64;
//     public static final int BETWEEN = 128;
// }
// 
// Path: src/main/java/com/github/brunodles/retrofunctions/Consumer.java
// @FunctionalInterface
// public interface Consumer<T> {
// 
//     /**
//      * Performs this operation on the given argument.
//      *
//      * @param t the input argument
//      */
//     void accept(T t);
// 
// }
// 
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
// 
//     /**
//      * Performs this operation on the given argument.
//      *
//      * @param value the input argument
//      */
//     void accept(int value);
// 
// }
// 
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
//     try {
//         if (condition.getAsBoolean()) block.accept(error);
//     } catch (Exception e) {
//     }
// }


import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.Consumer;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if;
package com.github.brunodles.javavalidation.matcher;



/**
 * Created by bruno on 03/06/16.
 */
public class StringMatcher implements ObjectMatcher<String, StringMatcher>,
        EqualsMatcher<String, StringMatcher> {
    private String value;
    private IntConsumer adder;

    StringMatcher(String value, IntConsumer adder) {
        this.value = value;
        this.adder = adder;
    }

    /**
     * Check if the reference String is empty
     *
     * @return the current object, to be used as a builder
     */
    public StringMatcher isEmpty() {
        _if(() -> value.isEmpty(), adder, Errors.EMPTY);
        return this;
    }

    /**
     * Check if the reference String is null
     *
     * @return the current object, to be used as a builder
     */
    @Override
    public StringMatcher isNull() {
        _if(() -> value == null, adder, Errors.NULL);
        return this;
    }

    /**
     * Check if the length of the reference String is matching
     *
     * @param matcher a {@link IntegerMatcher} will passed as parameter to the Consumer
     * @return the current object, to be used as a builder
     */
// Path: src/main/java/com/github/brunodles/javavalidation/Errors.java
// public class Errors {
//     // Object
//     public static final int NULL = 1;
//     public static final int EQUAL = 2;
// 
//     // Boolean
//     public static final int FALSE = 4;
//     public static final int TRUE = 8;
// 
//     // String
//     public static final int EMPTY = 16;
// 
//     // Integer
//     public static final int GREATER = 32;
//     public static final int LOWER = 64;
//     public static final int BETWEEN = 128;
// }
// 
// Path: src/main/java/com/github/brunodles/retrofunctions/Consumer.java
// @FunctionalInterface
// public interface Consumer<T> {
// 
//     /**
//      * Performs this operation on the given argument.
//      *
//      * @param t the input argument
//      */
//     void accept(T t);
// 
// }
// 
// Path: src/main/java/com/github/brunodles/retrofunctions/IntConsumer.java
// @FunctionalInterface
// public interface IntConsumer {
// 
//     /**
//      * Performs this operation on the given argument.
//      *
//      * @param value the input argument
//      */
//     void accept(int value);
// 
// }
// 
// Path: src/main/java/com/github/brunodles/javavalidation/matcher/Common.java
// static void _if(BooleanSupplier condition, IntConsumer block, int error) {
//     try {
//         if (condition.getAsBoolean()) block.accept(error);
//     } catch (Exception e) {
//     }
// }


// Path: src/main/java/com/github/brunodles/javavalidation/matcher/StringMatcher.java
import com.github.brunodles.javavalidation.Errors;
import com.github.brunodles.retrofunctions.Consumer;
import com.github.brunodles.retrofunctions.IntConsumer;
import static com.github.brunodles.javavalidation.matcher.Common._if;

package com.github.brunodles.javavalidation.matcher;



/**
 * Created by bruno on 03/06/16.
 */
public class StringMatcher implements ObjectMatcher<String, StringMatcher>,
        EqualsMatcher<String, StringMatcher> {
    private String value;
    private IntConsumer adder;

    StringMatcher(String value, IntConsumer adder) {
        this.value = value;
        this.adder = adder;
    }

    /**
     * Check if the reference String is empty
     *
     * @return the current object, to be used as a builder
     */
    public StringMatcher isEmpty() {
        _if(() -> value.isEmpty(), adder, Errors.EMPTY);
        return this;
    }

    /**
     * Check if the reference String is null
     *
     * @return the current object, to be used as a builder
     */
    @Override
    public StringMatcher isNull() {
        _if(() -> value == null, adder, Errors.NULL);
        return this;
    }

    /**
     * Check if the length of the reference String is matching
     *
     * @param matcher a {@link IntegerMatcher} will passed as parameter to the Consumer
     * @return the current object, to be used as a builder
     */
    public StringMatcher length(Consumer<IntegerMatcher> matcher) {