ninja-servlet/src/main/java/ninja/servlet/NinjaServletContext.java
private <T> Map<String, List<T>> toUnmodifiableMap(Multimap<String, T> multimap) {
        Map<String, List<T>> map = new HashMap<>(multimap.size());
        
        for (Entry<String, Collection<T>> entry: multimap.asMap().entrySet()) {
            Collection<T> value = entry.getValue();
            if (value == null) {
                Collections.emptyList();
            } else if (value instanceof List) {
                map.put(entry.getKey(), (List<T>)value);
            } else {
                map.put(entry.getKey(), new ArrayList<>(value));
            }
        }
        
        return Collections.unmodifiableMap(map);
    }
private <T> Map<String, List<T>> toUnmodifiableMap(Multimap<String, T> multimap) {
        Map<String, List<T>> map = new HashMap<>(multimap.size());
        
        for (Entry<String, Collection<T>> entry: multimap.asMap().entrySet()) {
            Collection<T> value = entry.getValue();
            if (value == null) {
                Collections.emptyList();
            } else if (value instanceof List) {
                map.put(entry.getKey(), (List<T>)value);
            } else {
                map.put(entry.getKey(), new ArrayList<>(value));
            }
        }
        
        return Collections.unmodifiableMap(map);
    }
private < T > Map < String , List < T > > toUnmodifiableMap ( Multimap < String , T > multimap ) { Map < String , List < T > > map = new HashMap <> ( multimap . size ( ) ) ; for ( Entry < String , Collection < T > > entry : multimap . asMap ( ) . entrySet ( ) ) { Collection < T > value = entry . getValue ( ) ; if ( value == null ) { Collections . emptyList ( ) ; } else if ( value instanceof List ) { map . put ( entry . getKey ( ) , ( List < T > ) value ) ; } else { map . put ( entry . getKey ( ) , new ArrayList <> ( value ) ) ; } } return Collections . unmodifiableMap ( map ) ; }
Utility method to convert a Guava Multimap to an unmodifiable Map that
uses a List<T> as a value. Optimized for the case where values are already
internally stored as a List<T> (e.g. ArrayListMultimap).
@param <T> The value type
@param multimap The multimap to convert from
@return The unmodifiable converted map
Utility method to convert a Guava Multimap to an unmodifiable Map that uses a List<T > as a value . Optimized for the case where values are already internally stored as a List<T > ( e . g . ArrayListMultimap ) .