Java Assert assertHasText(String str)

Here you can find the source of assertHasText(String str)

Description

assert Has Text

License

Apache License

Declaration

public static void assertHasText(String str) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static void assertHasText(String str) {
        if (!hasText(str))
            throw new IllegalArgumentException("no text in str");
    }/*from w ww  .j  ava  2s  .  c  o  m*/

    public static boolean hasText(String str) {
        if (!hasLength(str)) {
            return false;
        }
        int strLen = str.length();
        for (int i = 0; i < strLen; i++) {
            if (!Character.isWhitespace(str.charAt(i))) {
                return true;
            }
        }
        return false;
    }

    public static boolean hasLength(String str) {
        return (str != null && str.length() > 0);
    }
}

Related

  1. assertGreater(long first, long second)
  2. assertGreaterOrEqualsThan(final long value, final long limit, final String name)
  3. assertGreaterThanOrEquals(String name, double comparedTo, double number)
  4. assertHasInterface(Class interfaceClass, Class objectClass)
  5. assertHasLength(String... params)
  6. assertHexOrDecLongValue(String value)
  7. assertInBounds(final String param, final int value, final int min, final int max)
  8. assertInBounds(int[] coordinates)
  9. assertIndex(final int size, final int index)