views:

27

answers:

2

Following is the Annotation Code

public @interface ColumnName {
   String value();
   String datatype();
 }

I would like to make datatype an optional parameter. ie.

@ColumnName(value="password") should be a valid code.
+2  A: 

Seems like first example of the official documentation says it all ...

/**
 * Describes the Request-For-Enhancement(RFE) that led
 * to the presence of the annotated API element.
 */
public @interface RequestForEnhancement {
    int    id();
    String synopsis();
    String engineer() default "[unassigned]"; 
    String date();    default "[unimplemented]"; 
}
Riduidel
i only looked at the tutorials.ie why i couldnt find this.may i know the difference between unassigned and unimplemented
cdb
+1  A: 

To make it optional you can assign it a default value like that:

public @interface ColumnName {
   String value();
   String datatype() default "String";
 }

Then it doesn't need to be specified when using the Annotation.

Johannes Wachter