Util: Singleton OrderedProperties comparator

This commit is contained in:
zzz
2020-10-15 11:54:43 +00:00
parent e54950e02e
commit 7c1798513d

View File

@ -31,6 +31,8 @@ import java.util.TreeSet;
*/ */
public class OrderedProperties extends Properties { public class OrderedProperties extends Properties {
private static final EntryComparator ECOMP = new EntryComparator();
public OrderedProperties() { public OrderedProperties() {
super(); super();
} }
@ -46,7 +48,7 @@ public class OrderedProperties extends Properties {
public Set<Map.Entry<Object, Object>> entrySet() { public Set<Map.Entry<Object, Object>> entrySet() {
if (size() <= 1) if (size() <= 1)
return super.entrySet(); return super.entrySet();
TreeSet<Map.Entry<Object, Object>> rv = new TreeSet<Map.Entry<Object, Object>>(new EntryComparator()); TreeSet<Map.Entry<Object, Object>> rv = new TreeSet<Map.Entry<Object, Object>>(ECOMP);
rv.addAll(super.entrySet()); rv.addAll(super.entrySet());
return Collections.unmodifiableSortedSet(rv); return Collections.unmodifiableSortedSet(rv);
} }