Skip to content

Instantly share code, notes, and snippets.

@hrules6872
Created May 12, 2015 08:58
Show Gist options
  • Save hrules6872/5e423b4aa5d048ba5d38 to your computer and use it in GitHub Desktop.
Save hrules6872/5e423b4aa5d048ba5d38 to your computer and use it in GitHub Desktop.
SafeStringUtils
public class SafeStringUtils {
public static boolean safeEquals(Object o1, Object o2) {
return o1 != null && o1.equals(o2);
}
public static boolean safeEqualsIgnoreCase(String s1, String s2) {
return s1 != null && s1.equalsIgnoreCase(s2);
}
public static boolean safeIsEmpty(String s) {
return s != null && s.isEmpty();
}
public static boolean safeContains(String s1, CharSequence cs) {
return !(s1 == null || cs == null) && s1.contains(cs);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment