Composite パターンを用いてディレクトリ構造を表すJavaプログラムの例を示す。 このプログラムは、 枝を表すクラス : Folderクラス 葉を表すクラス : Fileクラス 共通インタフェース : FileInterfaceインタフェース 実行例を示すためのクラス : DirectoryUserクラス から構成される。 import java.util.ArrayList; import java.util.List; interface FileInterface { public void defaultMethod(int depth); public List<FileInterface> getChildren(); public boolean addComponent(FileInterface c); public boolean removeComponent
