I need to make sure that a map content is final, it is once initialized by:
Map<K, V> map = new HashMap<K, V>(iAnotherMap);
Every calls to methods which modifiy the map content (as put, remove, replace ...) would end in errors.
But I still would be able to perform another:
map = new HashMap<K, V>(iAnotherMap);
Is there any way to achieve this ?
Thanks
EDIT: Trying the Collections.unmodifiableMap approach, but there's an issue:
The class I want to wrap is:
public class IndexedHashMap<K, T> implements Map<K, Pair< Integer, T >>, Serializable
The following code returns an error:
IndexedHashMap< K, T > mCurrent = new IndexedHashMap< K, T >();
IndexedHashMap< K, T > mConstantCurrent = Collections.unmodifiableMap(mCurrent);'
Type mismatch: cannot convert from Map> to IndexedHashMap
Any idea about this ?