Is there a map implementation for Java listeners?
•
Java
I want a map implementation where I can add listeners for put () events
What is available in standards or any third-party library?
Solution
I don't know any standards or third parties, but it's easy to create a class that wraps another map and implements the map interface:
public class MapListener<K,V> implements Map<K,V> { private final Map<K,V> delegatee; public MapListener(Map<K,V> delegatee) { this.delegatee = delegatee; } // implement all Map methods,with callbacks you need. }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码