以下のように、ゲッターにいくつかの注釈があります。同じクラスのブール値に基づくゲッターでのすべてのアノテーション呼び出しをスキップしたいと思います。それを行う方法はありますか?
@MyAnnotation1(message = "{someMessage1}")
@MyAnnotation2(message = "{someMessage2}")
public Date getFromDate() {
return fromDate;
}
以下のように、ゲッターにいくつかの注釈があります。同じクラスのブール値に基づくゲッターでのすべてのアノテーション呼び出しをスキップしたいと思います。それを行う方法はありますか?
@MyAnnotation1(message = "{someMessage1}")
@MyAnnotation2(message = "{someMessage2}")
public Date getFromDate() {
return fromDate;
}
@Ignore
その注釈付きフィールドが設定されている場合は、そのフィールド上に別の注釈を定義できます。注釈処理は無視してかまいません。
@Ignore
private boolean value;
独自の注釈を次のように定義できます
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
/**
* This Annotation should be used on boolean field to set specify whether annotation processing should be ignored for that class
*/
public @interface Ignore {
}
これはカスタムアノテーションであるため、処理するコードを作成する必要があることを忘れないでください
PS注:カスタムアノテーションを作成していると仮定します。そしてそこに処理があります。