How to use custom type annotations in Java

前端 未结 3 1073
[愿得一人]
[愿得一人] 2021-02-14 13:21

Java 8 has feature called Type annotations (JSR 308). I would like to use it for simple Object to Object mapper framework. I would like define annotation @ExpectedType like this

3条回答
  •  故里飘歌
    2021-02-14 13:31

    @Documented
    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.FIELD)
    public @interface SearchDefinition {
    
        public String identifier() default "";
    
    }
    

    @SearchDefinition - can be used anywhere

提交回复
热议问题