forked from avni-bahmni-integration/integration-service
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#96 - deprecated some methods searching subject by providing beginnin…
…g of time. can be removed in future. util to compare string values.
- Loading branch information
1 parent
266fdcd
commit 9b1fe02
Showing
7 changed files
with
83 additions
and
25 deletions.
There are no files selected for viewing
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
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
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
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
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
25 changes: 25 additions & 0 deletions
25
util/src/main/java/org/avni_integration_service/util/ObjectUtil.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.avni_integration_service.util; | ||
|
||
import org.springframework.util.ObjectUtils; | ||
|
||
public class ObjectUtil { | ||
public static boolean nullSafeEqualsIgnoreCase(Object o1, Object o2) { | ||
if (ObjectUtils.nullSafeEquals(o1, o2)) { | ||
return true; | ||
} | ||
if (o1 != null && o2 != null) { | ||
return ObjectUtil.nullSafeEqualsIgnoreCase((String) o1, (String) o2); | ||
} | ||
return false; | ||
} | ||
|
||
public static boolean nullSafeEqualsIgnoreCase(String o1, String o2) { | ||
if (ObjectUtils.nullSafeEquals(o1, o2)) { | ||
return true; | ||
} | ||
if (o1 != null && o2 != null) { | ||
return o1.equalsIgnoreCase(o2); | ||
} | ||
return false; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
util/src/test/java/org/avni_integration_service/util/ObjectUtilTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.avni_integration_service.util; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class ObjectUtilTest { | ||
@Test | ||
public void nullSafeEqualsIgnoreCase() { | ||
assertTrue(ObjectUtil.nullSafeEqualsIgnoreCase("A", "a")); | ||
assertTrue(ObjectUtil.nullSafeEqualsIgnoreCase("A", "A")); | ||
assertTrue(ObjectUtil.nullSafeEqualsIgnoreCase(null, null)); | ||
assertFalse(ObjectUtil.nullSafeEqualsIgnoreCase(null, "a")); | ||
assertFalse(ObjectUtil.nullSafeEqualsIgnoreCase("a", "b")); | ||
} | ||
} |