package com.srbenoit.util;

/**
 * Utilities for working with strings.
 */
public final class StringUtils {

    /**
     * Private construct to prevent instantiation.
     */
    private StringUtils() {

        // No action
    }

    /**
     * Tests whether a string contains only whitespace characters.
     *
     * @param   str  the string to test
     * @return  <code>true</code> if the string contains only whitespace characters (or is empty);
     *          <code>false</code> if it contains non-whitespace characters
     */
    public static boolean isOnlyWhitespace(final String str) {

        int len;
        boolean isWhitespace = true;

        len = str.length();

        for (int i = 0; i < len; i++) {

            if (Character.isWhitespace(str.charAt(i))) {
                continue;
            }

            isWhitespace = false;

            break;
        }

        return isWhitespace;
    }
}
