package me.xdrop.ensurej;

import me.xdrop.ensurej.checks.CheckString;

public class StringHandler extends Handler<StringHandler> {

    private String s;

    public StringHandler(String s) {
        this.s = s;
    }

    /**
     * Checks whether the String contains all uppercase letters.
     * Please note that hello1 is passes this test.
     * See {@param allowNonChar}
     *
     * @return
     */
    public Chain<String, StringHandler> isAllLowercase(){
        return create(CheckString.isAllLowercase(true), s, "");
    }

    /**
     * Checks whether the String contains all lowercase letters.
     * Please note that hello1 is passes this test.
     * See {@param allowNonChar}
     *
     * @param allowNonChar Non-character entries are allowed
     * @return
     */
    public Chain<String, StringHandler> isAllLowercase(boolean allowNonChar){
        return create(CheckString.isAllLowercase(allowNonChar), s, "");
    }

    /**
     * Checks whether the String contains all uppercase letters.
     * Please note that HELLO1 is passes this test.
     *
     * @return
     */
    public Chain<String, StringHandler> isAllUppercase(){
        return create(CheckString.isAllUppercase(true), s, "");
    }

    /**
     * Checks whether the String contains all uppercase letters.
     * Please note that HELLO1 is passes this test.
     * See {@param allowNonChar}
     *
     * @param allowNonChar Non-character entries are allowed
     * @return
     */
    public Chain<String, StringHandler> isAllUppercase(boolean allowNonChar){
        return create(CheckString.isAllUppercase(allowNonChar), s, "");
    }


    /**
     * Checks whether the String matches the given pattern.
     *
     * @param regex Regex pattern
     * @return
     */
    public Chain<String, StringHandler> matches(String regex){
        return create(CheckString.matches(regex), s, "");
    }


    /**
     * Checks whether the String contains only letters
     *
     * @param unicode If false then we only check for latin a-zA-Z, otherwise
     *                {@code Character.isLetter()} is used which works with
     *                unicode letters too.
     * @return
     */
    public Chain<String, StringHandler> hasOnlyLetters(boolean unicode){
        return create(CheckString.hasOnlyLetters(unicode), s, "");
    }

    /**
     * Checks whether the String contains only letters
     *
     * @return
     */
    public Chain<String, StringHandler> hasOnlyLetters(){
        return create(CheckString.hasOnlyLetters(true), s, "");
    }

    /**
     * Checks whether the String contains only digits
     *
     * @return
     */
    public Chain<String, StringHandler> hasOnlyDigits(){
        return create(CheckString.hasOnlyDigits(), s, "");
    }

    /**
     * Checks whether the String is not null or and contains at least
     * one non-space character.
     *
     * @return
     */
    public Chain<String, StringHandler> isNotEmpty(){
        return create(CheckString.isNotEmpty(), s, "");
    }


    /**
     * Checks whether the String does not start with whitespace
     * @return
     */
    public Chain<String, StringHandler> hasStartWhitespace(){
        return create(CheckString.hasWhitespaceStart(), s, "");
    }


    /**
     * Checks whether the String does not end with whitespace
     * @return
     */
    public Chain<String, StringHandler> hasEndWhitespace(){
        return create(CheckString.hasWhitespaceEnd(), s, "");
    }

    /**
     * Checks whether the String does not contain extra whitespace at start or end.
     * This is effectively {@code hasEndWhitespace()} and {@code hasStartWhitespace()}
     * combined together.
     *
     * @return
     */
        public Chain<String, StringHandler> isTrimmed(){
            return create(CheckString.isTrimmed(), s, "");
        }

}

@@ -506,37 +506,77 @@
 Lowercase(true),
- s, %22
+%0A                s, %22String not all lowercase
 %22);%0A    %7D%0A%0A    /
@@ -957,32 +957,56 @@
 owNonChar), s, %22
+String not all lowercase
 %22);%0A    %7D%0A%0A    /
@@ -1263,34 +1263,74 @@
 ercase(true), s,
- %22
+%0A                %22String not all uppercase
 %22);%0A    %7D%0A%0A    /
@@ -1715,24 +1715,48 @@
 nChar), s, %22
+String not all uppercase
 %22);%0A    %7D%0A%0A%0A
@@ -1950,16 +1950,16 @@
 regex)%7B%0A
-
         
@@ -2000,24 +2000,52 @@
 regex), s, %22
+String doesn't match pattern
 %22);%0A    %7D%0A%0A%0A

Add some error messages