Skip to content

Instantly share code, notes, and snippets.

@solomax
Last active January 30, 2019 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solomax/a6fbec6db71bb28dfe53afc566086505 to your computer and use it in GitHub Desktop.
Save solomax/a6fbec6db71bb28dfe53afc566086505 to your computer and use it in GitHub Desktop.
commons-collections BidiMap values() test
package org.tmp;
import org.apache.commons.collections4.BidiMap;
import org.apache.commons.collections4.ListValuedMap;
import org.apache.commons.collections4.OrderedBidiMap;
import org.apache.commons.collections4.OrderedMap;
import org.apache.commons.collections4.OrderedMapIterator;
import org.apache.commons.collections4.SetValuedMap;
import org.apache.commons.collections4.SortedBidiMap;
import org.apache.commons.collections4.bidimap.DualTreeBidiMap;
import org.apache.commons.collections4.bidimap.TreeBidiMap;
import org.apache.commons.collections4.map.ListOrderedMap;
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
import org.apache.commons.collections4.multimap.HashSetValuedHashMap;
public class Test {
/*
* Method 'public java.util.Collection values()' has been added to an interface
* org.apache.commons.collections4.BidiMap
*/
private static void test1() {
System.out.println("Test1: ");
BidiMap<String, String> map = new TreeBidiMap<>();
map.put("A1", "B1");
map.put("A2", "B2");
map.put("A3", "B3");
map.put("A4", "B4");
map.put("A5", "B5");
map.put("A6", "B6");
for (String v : map.values()) {
System.out.println(v);
}
System.out.println();
}
/*
* Method 'public java.util.Collection get(java.lang.Object)' has been added to an interface
* org.apache.commons.collections4.ListValuedMap
*/
private static void test2() {
System.out.println("Test2: ");
ListValuedMap<String, String> map = new ArrayListValuedHashMap<>();
map.put("A1", "B1");
map.put("A1", "B2");
map.put("A1", "B3");
map.put("A1", "B4");
map.put("A2", "C1");
map.put("A2", "C2");
System.out.println(map.get("A1"));
System.out.println();
}
/*
* Method 'public java.util.Collection remove(java.lang.Object)' has been added to an interface
* org.apache.commons.collections4.ListValuedMap
*/
private static void test3() {
System.out.println("Test3: ");
ListValuedMap<String, String> map = new ArrayListValuedHashMap<>();
map.put("A1", "B1");
map.put("A1", "B2");
map.put("A1", "B3");
map.put("A1", "B4");
map.put("A2", "C1");
map.put("A2", "C2");
System.out.println(map.remove("A1"));
System.out.println();
}
/*
* Method 'public org.apache.commons.collections4.BidiMap inverseBidiMap()' has been added to an interface
* org.apache.commons.collections4.OrderedBidiMap
*/
private static void test4() {
System.out.println("Test4: ");
OrderedBidiMap<String, String> map = new TreeBidiMap<>();
map.put("A1", "B1");
map.put("A2", "B2");
map.put("A3", "B3");
map.put("A4", "B4");
map.put("A5", "B5");
map.put("A6", "B6");
System.out.println(map.inverseBidiMap());
System.out.println();
}
/*
* Method 'public org.apache.commons.collections4.MapIterator mapIterator()' has been added to an interface
* org.apache.commons.collections4.OrderedMap
*/
private static void test5() {
System.out.println("Test5: ");
OrderedMap<String, String> map = new ListOrderedMap<>();
map.put("A1", "B1");
map.put("A2", "B2");
map.put("A3", "B3");
map.put("A4", "B4");
map.put("A5", "B5");
map.put("A6", "B6");
for (OrderedMapIterator<String, String> iter = map.mapIterator(); iter.hasNext();) {
System.out.println(iter.next());
}
System.out.println();
}
/*
* Method 'public java.util.Collection get(java.lang.Object)' has been added to an interface
* org.apache.commons.collections4.SetValuedMap
*/
private static void test6() {
System.out.println("Test6: ");
SetValuedMap<String, String> map = new HashSetValuedHashMap<>();
map.put("A1", "B1");
map.put("A1", "B2");
map.put("A1", "B3");
map.put("A1", "B4");
map.put("A2", "C1");
map.put("A2", "C2");
System.out.println(map.get("A1"));
System.out.println();
}
/*
* Method 'public java.util.Collection remove(java.lang.Object)' has been added to an interface
* org.apache.commons.collections4.SetValuedMap
*/
private static void test7() {
System.out.println("Test7: ");
SetValuedMap<String, String> map = new HashSetValuedHashMap<>();
map.put("A1", "B1");
map.put("A1", "B2");
map.put("A1", "B3");
map.put("A1", "B4");
map.put("A2", "C1");
map.put("A2", "C2");
System.out.println(map.remove("A1"));
System.out.println();
}
/*
* Method 'public org.apache.commons.collections4.OrderedBidiMap inverseBidiMap()' has been added to an interface
* org.apache.commons.collections4.SortedBidiMap
*/
private static void test8() {
System.out.println("Test8: ");
OrderedBidiMap<String, String> map = new DualTreeBidiMap<>();
map.put("A1", "B1");
map.put("A2", "B2");
map.put("A3", "B3");
map.put("A4", "B4");
map.put("A5", "B5");
map.put("A6", "B6");
System.out.println(map.inverseBidiMap());
System.out.println();
}
/*
* Method 'public org.apache.commons.collections4.BidiMap inverseBidiMap()' has been added to an interface
* org.apache.commons.collections4.SortedBidiMap
*/
private static void test9() {
System.out.println("Test9: ");
SortedBidiMap<String, String> map = new DualTreeBidiMap<>();
map.put("A1", "B1");
map.put("A2", "B2");
map.put("A3", "B3");
map.put("A4", "B4");
map.put("A5", "B5");
map.put("A6", "B6");
System.out.println(map.inverseBidiMap());
System.out.println();
}
public static void main(String[] args) {
test1();
test2();
test3();
test4();
test5();
test6();
test7();
test8();
test9();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment