Java Reference
In-Depth Information
14.
15. public void addSupportingDocument(File document){
16. if (!supportingDocuments.contains(document)){
17. supportingDocuments.add(document);
18. }
19. }
20.
21. public void removeSupportingDocument(File document){
22. supportingDocuments.remove(document);
23. }
24.
25. public String toString(){
26. return getProjectItem().toString() + EOL_STRING
27. + "\tSupporting Documents: " + supportingDocuments;
28. }
29. }
The benefit of defining additional capabilities in this way is that it is easy to create project items that have a
combination of capabilities. Using these classes, you can make a simple task that depends on another project item,
or a task with supporting documents. You can even chain Decorators together and create a task that depends on
another task and has supporting documents. This flexibility is a key strength of the Decorator pattern.
Search WWH ::




Custom Search