Return Collections.unmodifiableMap(map)
, which provides an unmodifiable view of the Map
it wraps. Quoting from the Javadocs for that method:
Returns an unmodifiable view of the specified map. This method allows modules to provide users with "read-only" access to internal maps. Query operations on the returned map "read through" to the specified map, and attempts to modify the returned map, whether direct or via its collection views, result in an UnsupportedOperationException.