「Spring」@Target、@Documentedアノテーションのサンプル

書式
1.@Documented
このアノテーションを使うにあたって、javadoc などによる文章化が必要であることを示します。
2.@Target
アノテーションをつける対象です。{} で囲んで複数指定できます。
対象の種類:FIELD(フィールド・ENUM)
3.@Retention
アノテーションが影響する範囲を記述しています。
RUNTIME : class ファイルに記録され、かつ、実行時に参照できます。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface UserControlAuth {
  
String userName() default "";
}
@Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface UserControlAuth {    String userName() default ""; }
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface UserControlAuth {
  
  String userName() default "";
  
}

 

SpringMVC

Posted by arkgame