Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.


JavaWorld Talkback >> 959164

Pages: 1
Anonymous
Unregistered




Multiple occurance of Custom Annotation
      #15563 - 02/16/05 01:10 AM

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...


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
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

Rate this topic

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5