*> Attribute on a class
class-id Attributes
attribute Author(name AuthorName = "Benjamin Franklin").
*> Attribute on a field
01 book string attribute Author(name AuthorName = "Benjamin Franklin").
*> Attribute on a property
01 bookProperty string property
attribute Author(name AuthorName = "Benjamin Franklin").
*> Attribute on a method and argument
method-id GetAnotherBook
attribute Author(name AuthorName = "Benjamin Franklin")
(arg1 as string
attribute Author(name AuthorName = "Benjamin Franklin"))
returning return-value as string.
set return-value to book
end method.
end class.
*> Attribute definition
attribute-id AuthorAttribute public.
01 AuthorName string property.
end attribute.
|
// Java terminology : annotation
// Annotation definition
import java.lang.annotation.*;
// Annotation on a class
@authorAttribute(authorName = "Benjamin Franklin")
public class attributes {
// Annotation on a field
@authorAttribute(authorName = "Benjamin Franklin")
String book;
// Annotation on a method
@authorAttribute(authorName = "Benjamin Franklin")
String getTheBook() {
return book;
}
// Annotation on an argument
@authorAttribute(authorName = "Benjamin Franklin")
String getAnotherBook(
@authorAttribute(authorName = "Benjamin Franklin") String arg1) {
return book;
}
}
// Annotation declaration
@Retention(RetentionPolicy.RUNTIME)
@interface authorAttribute {
public String authorName();
}
|