001 package com.nimbusds.oauth2.sdk.util; 002 003 004 /** 005 * String utilities. 006 * 007 * @author Vladimir Dzhuvinov 008 * @version $version$ (2012-10-10) 009 */ 010 public class StringUtils { 011 012 013 /** 014 * Returns {@code true} if the specified string is not {@code null} and 015 * contains non-whitespace characters. 016 * 017 * @param s The string to check. May be {@code null}. 018 * 019 * @return {@code true} if the string is not {@code null} and contains 020 * non-whitespace characters, else {@code false}. 021 */ 022 public static boolean isDefined(final String s) { 023 024 if (s != null && ! s.trim().isEmpty()) 025 return true; 026 else 027 return false; 028 } 029 030 031 /** 032 * Returns {@code true} if the specified string is {@code null} or 033 * contains whitespace characters only. 034 * 035 * @param s The string to check. May be {@code null}. 036 * 037 * @return {@code true} if the string is {@code null} or contains 038 * whitespace characters only, else {@code false}. 039 */ 040 public static boolean isUndefined(final String s) { 041 042 if (s == null || s.trim().isEmpty()) 043 return true; 044 else 045 return false; 046 } 047 048 049 /** 050 * Prevents public instantiation. 051 */ 052 private StringUtils() { 053 054 // Nothing to do 055 } 056 }