예제 #1
0
파일: Maps.java 프로젝트: automenta/corenlp
 /**
  * Adds the value to the collection given by map.get(key). A new collection is created using the
  * supplied CollectionFactory.
  */
 public static <K, V, C extends Collection<V>> void putIntoValueCollection(
     Map<K, C> map, K key, V value, CollectionFactory<V> cf) {
   C c = map.get(key);
   if (c == null) {
     c = ErasureUtils.<C>uncheckedCast(cf.newCollection());
     map.put(key, c);
   }
   c.add(value);
 }
예제 #2
0
파일: Maps.java 프로젝트: automenta/corenlp
 /** Adds the value to the ArrayList given by map.get(key), creating a new ArrayList if needed. */
 public static <K, V> void putIntoValueArrayList(Map<K, List<V>> map, K key, V value) {
   CollectionFactory<V> factory = CollectionFactory.arrayListFactory();
   putIntoValueCollection(map, key, value, factory);
 }
예제 #3
0
파일: Maps.java 프로젝트: automenta/corenlp
 /** Adds the value to the HashSet given by map.get(key), creating a new HashMap if needed. */
 public static <K, V> void putIntoValueHashSet(Map<K, Set<V>> map, K key, V value) {
   CollectionFactory<V> factory = CollectionFactory.hashSetFactory();
   putIntoValueCollection(map, key, value, factory);
 }
 @Test
 public void createRawLists() {
   Tuple<List> tuple = LIST_FACTORY.createValues(RAWLIST_TYPETAG, prefabValues, typeStack);
   assertEquals(listOf(redObject), tuple.getRed());
   assertEquals(listOf(blackObject), tuple.getBlack());
 }
 @Test
 public void createSetsOfString() {
   Tuple<Set> tuple = SET_FACTORY.createValues(STRINGSET_TYPETAG, prefabValues, typeStack);
   assertEquals(setOf(red), tuple.getRed());
   assertEquals(setOf(black), tuple.getBlack());
 }
 @Test
 public void createListsOfString() {
   Tuple<List> tuple = LIST_FACTORY.createValues(STRINGLIST_TYPETAG, prefabValues, typeStack);
   assertEquals(listOf(red), tuple.getRed());
   assertEquals(listOf(black), tuple.getBlack());
 }