Created
May 12, 2015 08:58
-
-
Save hrules6872/5e423b4aa5d048ba5d38 to your computer and use it in GitHub Desktop.
SafeStringUtils
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
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