ClassUtils.comparator().
This commit is contained in:
parent
e09ad8a91a
commit
7d9d4d41a6
|
@ -60,6 +60,7 @@ The <action> type attribute can be add,update,fix,remove.
|
|||
<action type="add" dev="ggregory" due-to="Gary Gregory">Add and use ObjectUtils.getClass(T).</action>
|
||||
<action type="add" dev="ggregory" due-to="Gary Gregory">Add and use ArrayUtils.newInstance(Class>T>, int).</action>
|
||||
<action type="add" dev="ggregory" due-to="Gary Gregory">Add and use null-safe Streams.of(T...).</action>
|
||||
<action type="add" dev="ggregory" due-to="Gary Gregory">Add ClassUtils.comparator().</action>
|
||||
<!-- UPDATE -->
|
||||
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump spotbugs-maven-plugin from 4.2.0 to 4.2.3 #735.</action>
|
||||
<action type="update" dev="ggregory" due-to="Dependabot, XenoAmess">Bump Bump actions/cache from v2.1.4 to v2.1.6 #742, #752, #764.</action>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -36,6 +36,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.commons.lang3.ClassUtils.Interfaces;
|
||||
import org.apache.commons.lang3.reflect.testbed.GenericConsumer;
|
||||
|
@ -1137,6 +1138,24 @@ public class ClassUtilsTest {
|
|||
assertFalse(ClassUtils.isInnerClass(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComparable() {
|
||||
final TreeMap<Class<?>, String> map = new TreeMap<>(ClassUtils.comparator());
|
||||
map.put(String.class, "lastEntry");
|
||||
map.toString();
|
||||
map.put(Character.class, "firstEntry");
|
||||
map.toString();
|
||||
assertEquals("firstEntry", map.firstEntry().getValue());
|
||||
assertEquals(Character.class, map.firstEntry().getKey());
|
||||
//
|
||||
assertEquals("lastEntry", map.lastEntry().getValue());
|
||||
assertEquals(String.class, map.lastEntry().getKey());
|
||||
//
|
||||
map.put(null, "null");
|
||||
map.toString();
|
||||
assertEquals("null", map.get(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructor() {
|
||||
assertNotNull(new ClassUtils());
|
||||
|
|
Loading…
Reference in New Issue