Chapter 13 Working with Java
Java 5.0 Annotations
PowerDesigner provides full support for Java 5.0 annotations, which allow you to add metadata to your code. This metadata can be accessed by post-processing tools or at run-time to vary the behavior of the system.
You can use built-in annotations, such as those listed below, and also create your own annotations, to apply to your types.
There are three types of annotations available:
- Normal annotations – which take multiple arguments
- Single member annotations – which take only a single argument, and which have a more compact syntax
- Marker annotations – which take no parameters, and are used to instruct the Java compiler to process the element in a particular way
PowerDesigner supports the seven built-in Java 5.0 annotations:
- java.lang.Override - specifies that a method declaration will override a method declaration in a superclass, and will generate a compile-time error if this is not the case.
- java.lang.Deprecated – specifies that an element is deprecated, and generates a compile-time warning if it is used in non-deprecated code.
- java.lang.SuppressWarning – specifies compile-time warnings that should be suppressed for the element.
- java.lang.annotation.Documented – specifies that annotations with a type declaration are to be documented by javadoc and similar tools by default to become part of the public API of the annotated elements.
- java.lang.annotation.Inherited – specifies that an annotation type is automatically inherited for a superclass
- java.lang.annotation.Retention – specifies how far annotations will be retained during processing. Takes one of the following values:
- SOURCE – annotations are discarded at compile-time
- CLASS – [default] annotations are retained by the compiler, but discarded at run-time
- RUNTIME – annotations are retained by the VM at run-time
- java.lang.annotation.Target – restricts the kind of program element to which an annotation may be applied and generates compile-time errors. Takes one of the following values:
- TYPE – class, interface, or enum declaration
- FIELD – including enum constants
- METHOD
- PARAMETER
- CONSTRUCTOR
- LOCAL_VARIABLE
- PACKAGE
For general information about modeling this form of metadata in PowerDesigner, see "Attributes (OOM)" in the Building Structural Diagrams chapter.
Copyright (C) 2007. Sybase Inc. All rights reserved.
|
|