java - How to use annotation in an annotation? -


given:

public @interface myannotation(){     public sometype[] value(); } 

in java 7 possible like:

@myannotation({     value1,     @myannotation({subvalue1, subvalue2, ...}) value2,     ...     valuen }) public object someproperty; 

?

you can. example jackson library (leaving out comments):

package com.fasterxml.jackson.annotation;  import java.lang.annotation.elementtype; import java.lang.annotation.retention; import java.lang.annotation.retentionpolicy; import java.lang.annotation.target;  @target({elementtype.annotation_type, elementtype.type, elementtype.field,     elementtype.method, elementtype.parameter}) @retention(retentionpolicy.runtime) @jacksonannotation public @interface jsonsubtypes {     public type[] value();      public @interface type {         /**          * class of subtype          */         public class<?> value();          /**          * logical type name used type identifier class          */         public string name() default "";     } } 

and here example usage:

@jsonsubtypes({         @jsonsubtypes.type(value = testsystemevent.class, name = "testevent"), }) public interface systemevent { } 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -