Recipe 16.2. Declaring Inheritance Between ClassesProblemYou want to introduce a new inheritance relationship between two classes. SolutionUse the declare parents statement to specify a particular class that extends from another class. DiscussionExample 16-2 shows how a new inheritance relationship can be specified for the MyClass class. Example 16-2. Adding a new inheritance relationship between classespublic aspect IntroduceInheritanceRecipe { declare parents : MyClass extends AnotherClass; } Figure 16-2 shows the class structure of the MyClass class before and after the aspect in Example 16-2 is applied. Figure 16-2. The MyClass class before and after the aspect introduces a new inheritance relationshipSee AlsoRecipe 16.3 shows how to apply new interfaces to an existing class using aspects. |