/* * Created on Jan 7, 2005 * * @author Mohan Radhakrishnan */ //package com.blueprint.ui.util; import java.lang.ref.ReferenceQueue; import java.lang.ref.SoftReference; import java.util.AbstractMap; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; /* * Undo/redo for each shape. This can be used to maintain * a list of changes to rollback. Since the calls to the * model tier are direct and the reverse calls to update the * UI are Commands, this list is for the latter. */ public class ShapeCommandMap extends AbstractMap { private final Map> internalMap = new HashMap>(); private final ReferenceQueue queue = new ReferenceQueue(); public V put( K key, V value ){ //remove stale entries SoftReference ref = new SoftReference( value, queue ); SoftReference s = internalMap.put( key, ref ); return ( s != null ? s.get() : null ); } /*public V get( K key ){ //remove stale entries SoftReference value = internalMap.get( key ); return ( value != null ? value.get() : null ); }*/ public Set> entrySet(){ Set> commands = new LinkedHashSet>(); for( final Entry> entry : internalMap.entrySet() ){ final V value = entry.getValue().get(); commands.add( new Entry(){ public K getKey(){ return entry.getKey(); } public V getValue(){ return value; } public V setValue( V v ){ entry.setValue( new SoftReference( v, queue ) ); return value; } }); } return commands; } } aspect TriggerBug { public void foo() { ShapeCommandMap map = new ShapeCommandMap(); map.put("hi","there"); } before() : execution(* getValue(..)) { System.out.println("a matching call"); } } ption value='add-caldav-repair-middleware'>add-caldav-repair-middleware Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
blob: 426bfc5d6d5a0a11c5d53cb1b0b62329b9a5320d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53