aboutsummaryrefslogtreecommitdiffstats
path: root/tests/generated/test/SomeEventsAspect.aj
blob: f661f237cc338f7fcc401659c337fdb589d2c66a (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
package test;
import java.util.ArrayList;
import java.util.Collection;

/**
 * Events for test.Some.
 *
 * @author test.SimpleProcessor
 */
@javax.annotation.Generated("test.SimpleProcessor")
final aspect SomeEventsAspect {

  public static final class SomeOnMethod1Event {
    private Collection<SomeCallbacks.OnMethod1> callbacks = null;

    SomeOnMethod1Event() {
    }

    public void add(SomeCallbacks.OnMethod1 callback) {
      Collection<SomeCallbacks.OnMethod1> callbacksSafe = callbacks;
      if (callbacksSafe == null) {
        callbacksSafe = new ArrayList<>(1);
        callbacks = callbacksSafe;
      }
      callbacksSafe.add(callback);
    }

    public void clean() {
      callbacks = null;
    }
  }

  private static void emit(SomeOnMethod1Event event, Some emmiter) {
    final Collection<SomeCallbacks.OnMethod1> callbacksSafe = event.callbacks;
    if (callbacksSafe == null)
      return;
    for (final SomeCallbacks.OnMethod1 callback : new ArrayList<>(callbacksSafe))
      callback.changed(emmiter);
  }

  @SuppressWarnings("PublicField")
  public final SomeOnMethod1Event test.Some.OnMethod1Event = new SomeOnMethod1Event();

  before(): execution(void test.Some.method1()) {
    final test.Some emmiter = (test.Some) thisJoinPoint.getThis();
    emit(emmiter.OnMethod1Event, emmiter);
  }

}