|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | ||||||||
@Documented @Target(value=TYPE) public @interface NotContainable
The class to which this annotation is applied is not containable. That is, instances of the class can not be safely encapsulated via region aggregation into other objects because methods of this class leak references to themselves or other objects that they reference, transitively.
This annotation primarily exists for clarifying the non-containability of a class that might otherwise be assumed to be containable, despite the fact that it is a bad idea to assume a class is containable without good reason.
This annotation is trusted, i.e., it is not verified. Its use is for documentation.
A type may not be annotated with both @Containable
and @NotContainable.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
@NotContainable
public final class ControlPanel extends JPanel implements ActionListener {
public ControlPanel() {
final JButton exit = new JButton("Press to Exit");
add(exit, BorderLayout.CENTER);
exit.addActionListener(this);
}
private boolean f_exitPressed = false;
public void actionPerformed(ActionEvent e) {
f_exitPressed = true;
}
public boolean exitPressed() {
return f_exitPressed;
}
}
@annotate tag.
/**
* @annotate NotContainable
*/
public final class ControlPanel extends JPanel implements ActionListener {
...
}
Containable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | ||||||||