Example usage for org.apache.commons.collections4 Trie prefixMap

List of usage examples for org.apache.commons.collections4 Trie prefixMap

Introduction

In this page you can find the example usage for org.apache.commons.collections4 Trie prefixMap.

Prototype

SortedMap<K, V> prefixMap(K key);

Source Link

Document

Returns a view of this Trie of all elements that are prefixed by the given key.

Usage

From source file:cherry.foundation.telno.AreaCodeTableFactoryTest.java

@Test
public void test() throws Exception {

    List<Resource> resources = new ArrayList<>(9);
    resources.add(new ClassPathResource("cherry/goods/telno/soumu/000124070.xls"));
    resources.add(new ClassPathResource("cherry/goods/telno/soumu/000124071.xls"));
    resources.add(new ClassPathResource("cherry/goods/telno/soumu/000124072.xls"));
    resources.add(new ClassPathResource("cherry/goods/telno/soumu/000124073.xls"));
    resources.add(new ClassPathResource("cherry/goods/telno/soumu/000124074.xls"));
    resources.add(new ClassPathResource("cherry/goods/telno/soumu/000124075.xls"));
    resources.add(new ClassPathResource("cherry/goods/telno/soumu/000124076.xls"));
    resources.add(new ClassPathResource("cherry/goods/telno/soumu/000124077.xls"));
    resources.add(new ClassPathResource("cherry/goods/telno/soumu/000124078.xls"));
    AreaCodeTableFactory factory = new AreaCodeTableFactory();
    factory.setSoumuExcelParser(new SoumuExcelParser());
    factory.setResources(resources);/*from  w  w w . ja  v a2s . c o  m*/

    Trie<String, Integer> trie = factory.getObject();
    SortedMap<String, Integer> map = trie.prefixMap("042");
    assertEquals(790, map.size());
    assertEquals(new TreeSet<Integer>(asList(2, 3, 4)), new TreeSet<>(map.values()));

    assertEquals(4554 + 5683 + 3400 + 5343 + 5307 + 3000 + 5548 + 4526 + 5330, trie.size());
    assertEquals(Trie.class, factory.getObjectType());
    assertFalse(factory.isSingleton());
}