Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.
Anonymous
Unregistered
|
|
I would like to know whether its possible to declare multiple times a same annotation: for e.g. If I have a annotation say:
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface MyAnnotation { String Name(); }
and use this annotation as following:
@MyAnnotation(Name = "First") @MyAnnotation(Name = "Second") public class TestAnnotation { }
Is the above usage possible? How?
In C#.NET the above can be done as follows:
[AttributeUsage(AttributeTargets.Class,AllowMultiple=true)] public class MyAnnotation: Attribute { }
and used as:
[MyAnnotation(Name = "First")] [MyAnnotation(Name = "Second")] public class TestAnnotation { public TestAnnotation(string name) { } }
Anyone knowing how to achieve the above... Thanks in advance...
|
|
0 registered and 1 anonymous users are browsing this forum.
Moderator:
Print Topic
|
Forum Permissions
You cannot start new topics
You cannot reply to topics
HTML is disabled
UBBCode is enabled
|
Rating:
Topic views: 8255
|
|
|
|
|
|
Powered by UBB.threads™ 6.5.5