Is there an implementation of java.util.Map that only allows a value to be read once? What I’d like to do is something like this:
Map map = new ReadOnceMap();
map.put("key", "value")
System.out.println(map.get("key")); // prints "value"
System.out.println(map.get("key")); // prints null
EDIT: requirements:
- existing implementation
- values are guaranteed to be read at most one time
Something like this?