Last active
December 11, 2015 11:58
-
-
Save benkn/4597460 to your computer and use it in GitHub Desktop.
Check if the given String is not null or has a value other than whitespace.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check that the given String is not null and has a value other than | |
* whitespace. | |
* | |
* {@code | |
* hasValue(null) = false | |
* hasValue("") = false | |
* hasValue(" ") = false | |
* hasValue("bob") = true | |
* hasValue(" bob ") = true | |
* } | |
* | |
* @param input String | |
* @return true if the input has a value, and false if not. | |
*/ | |
public static boolean hasValue(String input) { | |
if ( input != null && input.trim().length() > 0 ) { | |
return true; | |
} else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment