Java アノテーションに基づいて、アプリケーションの周りに検証メカニズムを構築しました。Java Bean の検証に似ていますが、唯一の例外は、私の方が簡単であることです。値のみがあり、値の型は ですFloat
。
@Target({ FIELD })
@Retention(RUNTIME)
@Documented
public @interface Min {
float value() default 0f;
}
ここで、値もサポートするようにこのメカニズムを拡張する必要がありInteger
ます。アノテーションのオーバーライドを提供することは可能ですか? 何かのようなもの:
@Target({ FIELD })
@Retention(RUNTIME)
@Documented
public @interface Min {
int value() default 0;
}
それとも、2 つのプロパティのうちの 1 つだけが存在する可能性はありますか? 何かのようなもの:
@Target({ FIELD })
@Retention(RUNTIME)
@Documented
public @interface Min {
float value() default 0f;
int intValue();
}
他のメカニズムは歓迎されます。
ありがとうございました!