List of usage examples for org.apache.commons.lang3 ArrayUtils toMap
public static Map<Object, Object> toMap(final Object[] array)
Converts the given array into a java.util.Map .
From source file:org.jasig.cas.extension.clearpass.EhcacheBackedMapTests.java
@Test public void verifyPutClear() { final String[][] arrayItems = { { "key0", "Item0" }, { "key1", "Item1" }, { "key2", "Item2" } }; final Map mapItems = ArrayUtils.toMap(arrayItems); this.map.putAll(mapItems); assertEquals(map.size(), 3);//from w w w . j a v a 2 s .com this.map.clear(); assertTrue(map.isEmpty()); }
From source file:org.jasig.cas.extension.clearpass.EhcacheBackedMapTests.java
@Test public void verifyKeysValues() { final String[][] arrayItems = { { "key0", "Item0" }, { "key1", "Item1" }, { "key2", "Item2" } }; final Map mapItems = ArrayUtils.toMap(arrayItems); this.map.putAll(mapItems); assertEquals(map.keySet().size(), 3); assertEquals(map.values().size(), 3); }
From source file:org.jasig.cas.extension.clearpass.EhcacheBackedMapTests.java
@Test public void verifyContains() { final String[][] arrayItems = { { "key0", "Item0" }, { "key1", "Item1" }, { "key2", "Item2" } }; final Map mapItems = ArrayUtils.toMap(arrayItems); this.map.putAll(mapItems); assertTrue(map.containsKey("key2")); assertTrue(map.containsValue("Item1")); }
From source file:org.ruogu.lang3.ArrayUtilsTest.java
public static void main(String[] args) { Class<?>[] classArray = new Class[0]; int[][] intArray = { { 1, 4, 6 }, { 2, 0, 7 } }; System.out.println(ArrayUtils.toString(intArray)); // map//from w w w. j a va 2s . com String[][] toMap1 = { { "k1", "v1" }, { "k2", "v2", "vv" } }; Map<Object, Object> map1 = ArrayUtils.toMap(toMap1); System.out.println(map1.toString()); // Entryamp Entry<String, String> o1 = new AbstractMap.SimpleEntry<String, String>("key1", "value1"); Entry<String, String> o2 = new AbstractMap.SimpleEntry<String, String>("key2", "value2"); Entry[] jj = new AbstractMap.SimpleEntry[2]; jj[0] = o1; jj[1] = o2; System.out.println(ArrayUtils.toMap(jj)); // Entry<String, String>[] jjs = new AbstractMap.SimpleEntry[2]; Entry<String, String>[] jjss = new Entry[2]; }
From source file:rus.cpuinfo.Ui.Fragments.CpuInfoTabTabFragment.java
private static Map createFragments() { return ArrayUtils.toMap(new Object[][] { { CPU, CpuInfoCpuFragment.newInstance() }, { DEVICE, CpuInfoDeviceFragment.newInstance() }, { SYSTEM, CpuInfoSystemFragment.newInstance() }, { BATTERY, CpuInfoBatteryFragment.newInstance() }, { SENSORS, CpuInfoSensorsFragment.newInstance() }, { ABOUT, CpuInfoAboutFragment.newInstance() } }); }