Java: Returning an Unmodifiable Collection but should be able to update the underlying Collection

I am facing a design problem where the requirement is as such I am maintaining a Map, say Map<String, List<String>>

I need to be able to return an unmodifiable instance of this Map so that no one accessing the API can tamper the underlying map.

Class InMemoryDB {

  private Map<String,List<String>> typeSlabValuesMap;

  public List<String> getSlabs(String typeValue){

    if (typeSlabValuesMap.containsKey(typeValue) {
      return Collections.unmodifiableList(typeSlabValuesMap.get(typeValue);
    }
    return Collections.emptyList();
  }
}

Now I should also be able to change the map as and when needed for, e.g.

  1. A new type comes in I should be able to add the type and slab values
  2. Slab values need to be changed I should be able to update the map with these values

Now assuming I can only expose the getSlabs in an unmodifiable List, how should I design the update part of this map as mentioned above?

All updates of your map should take place within your class (which seems to be desired by the original author of the class, anyway, since he used the Collections.unmodifiable wrapper). Provide public methods that validate and alter the map according to your business logic. Regarding your given examples:

  1. public void addNewType(String type, List<String> values)
  2. public void updateType(String type, List<String> values)

Both have the same signature, their content would be different. In these methods, do everything to prevent your map gets inconsistent.