USRE-87 Add two new class for common util

This commit is contained in:
YuCheng Hu 2021-11-30 11:15:43 -05:00
parent c904d1953c
commit 2dce8dfc7c
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,12 @@
package com.ossez.usreio.common.util;
import java.io.Serializable;
import java.util.Comparator;
public class CaseInsensitiveComparator<T> implements Comparator<T>, Serializable {
public int compare(Object o1, Object o2) {
String s1 = (String) o1;
String s2 = (String) o2;
return s1.compareToIgnoreCase(s2);
}
}

View File

@ -0,0 +1,17 @@
package com.ossez.usreio.common.util;
import java.util.Map;
import java.util.TreeMap;
public class CaseInsensitiveTreeMap<K, V> extends TreeMap<K, V> {
public CaseInsensitiveTreeMap(Map<K, V> map) {
this();
this.putAll(map);
}
public CaseInsensitiveTreeMap() {
super(new CaseInsensitiveComparator());
}
}