CommonStringMethods { public static boolean nullSafeEquals(String a, String b) { if (a == b) { return true; } if (a == null) { return false; } return a.equals(b); } private  CommonStringMethods(); static boolean isNullEmptyOrBlank(String string); static String safeTrim(String string); static boolean nullSafeEquals(String a, String b);  }
@Test public void testNullSafeEquals() { assertTrue(CommonStringMethods.nullSafeEquals(null, null)); assertFalse(CommonStringMethods.nullSafeEquals(null, "")); assertFalse(CommonStringMethods.nullSafeEquals("", null)); String sameStringObject = "This is the same string object"; assertTrue(CommonStringMethods.nullSafeEquals(sameStringObject, sameStringObject)); assertTrue(CommonStringMethods.nullSafeEquals("identical string", "identical string")); assertTrue(CommonStringMethods.nullSafeEquals("", "")); assertFalse(CommonStringMethods.nullSafeEquals("not identical", "to this")); }