code: public static int compare(String s1, String s2, boolean ignoreCase) {
        if (s1 == null && s2 == null) {
           return 0;
        } else if (s1 == null) {
           return -1;
        } else if (s2 == null) {
           return 1;
        }
        return ignoreCase ? s1.compareToIgnoreCase(s2) : s1.compareTo(s2);
     }
docs: Null safe comparison of strings
  
  @param s1         string 1
  @param s2         string 2
  @param ignoreCase True perform case insensitive comparison, False perform case sensitive comparison
  @return as long as neither are null