aboutsummaryrefslogtreecommitdiffstats
path: root/docs/teaching/demos/figures/scratch/HistoryUpdating.java
blob: f4eff3d3f32fc551f23817b0e61e9ac7f16c0673 (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
package figures.support;

import figures.*;

public aspect HistoryUpdating {

	pointcut moves(FigureElement fe):
		this(fe) &&
		execution(void FigureElement+.set*(..));
	
	after(FigureElement fe) returning: moves(fe) {
		Canvas.updateHistory(fe);
	}
	
	declare error:
		set(private * FigureElement+.*) &&
		!(withincode(void FigureElement+.set*(..)) ||
		  withincode(FigureElement+.new(..))): 
		"doh!!!";
	
	before(int newValue): 
		set(int Point.*) && args(newValue) {
		if (newValue < 0) {
			throw new IllegalArgumentException("too small");
		} 
	}
}