title: aspectj pointcut matching a specific annotation parameter value
body: <p>I'm trying to define a pointcut around a method annotated with a custom annotation. The annotation has one parameter that I would like to include a check in the pointcut definition.</p>
  
  <p>This is the annotation:</p>
  
  <pre><code>public @interface MyAnno {
    String[] types;
  }
  </code></pre>
  
  <p>An example of how the annotation could be applied:</p>
  
  <pre><code>public class MyClass {
    @MyAnno(types={"type1", "type2"})
    public void doSomething() {
      // ...
    }
    @MyAnno(types={"type3"})
    public void doSomethingElse() {
      // ...
    }
  }
  </code></pre>
  
  <p>Now I would like to have two pointcut definitions which select those two methods, based on the contents of the annotation.</p>
  
  <p>Creating a pointcut on the annotation itself is relatively easy:</p>
  
  <pre><code>@Pointcut("@annotation(myAnno)")
  public void pointcutAnno(MyAnno myAnno) {
  }
  
  @Pointcut("execution(* *(..)) &amp;&amp; pointcutAnno(myAnno)")
  public void pointcut(MyAnno myAnno) {
  }
  </code></pre>
  
  <p>This will match every occurrence of the of @MyAnno. But how can I define two pointcuts, one matching <code>@MyAnno</code> with <code>types</code> containing <code>"type1"</code> and the other matching <code>@MyAnno</code> with <code>types</code> containing <code>"type3"</code></p>