我对谷歌的
MapMaker
设计。我想知道这里使用的图案的名称是什么?
(我认为它有点像decorator模式,但在这个模式中,我们不需要将对象包装在其他对象中来扩展功能,但我无法确切地确定它是哪种模式。)
地图制作对象创建:
ConcurrentMap<Key, Graph> graphs = new MapMaker()
.concurrencyLevel(32)
.softKeys()
.weakValues()
.expiration(30, TimeUnit.MINUTES)
.makeComputingMap(
new Function<Key, Graph>() {
public Graph apply(Key key) {
return createExpensiveGraph(key);
}
});