public static < K , V > Map < K , V > toImmutableMap ( final Map < K , V > map ) { switch ( map . size ( ) ) { case 0 : return Collections . emptyMap ( ) ; case 1 : final Entry < K , V > entry = map . entrySet ( ) . iterator ( ) . next ( ) ; return Collections . singletonMap ( entry . getKey ( ) , entry . getValue ( ) ) ; default : return Collections . unmodifiableMap ( map ) ; } }
list to imuteable map .