Create a Java Annotation with IDE contextual behaviour

前端 未结 3 1574
Happy的楠姐
Happy的楠姐 2021-02-09 03:39

I\'ve created an Annotation

/**
 * Highlights this method is declared in XML
 */
public @interface FromXML {
}

I\'m using this on methods that

3条回答
  •  逝去的感伤
    2021-02-09 04:15

    Ok I can't do this in any easy way or form.

    Looking at the annotation package http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/package-summary.html

    I can't extend an annotation: Why is not possible to extend annotations in Java?

    I can't implement another annotation java.lang.Override

    I can't mimic / mock / pretend to be @Override

    If I add @Override to my @FromXML it is NOT inherited down the chain.

    The only way would be to create an Eclipse plugin that recognises my annotation and stops the warning. Shame because I can't find an easy way to do this.

    I also went down the route of creating an interface for my @FromXML entry points, this was very nice and communicated my Activity was of a type and therefore I didn't need the annotation anymore, perhaps this design change is the answer.

提交回复
热议问题