public classConcreComponentextendsAbsComponent{ public void OriginalComponent() { System.out.println("This is from OriginalComponent"); } }
public abstractclassAbsDecoratorextendsAbsComponent{ protectedAbsComponent component = null; public AbsDecorator(AbsComponent conponent) { this.component = conponent; } public void OriginalComponent() { component.OriginalComponent(); } }
public classConcreDecoratorextendsAbsDecorator{ public ConcreDecorator(AbsComponent conponent) { super(conponent); } public void selfFunction() { System.out.println("extend the original function with self function"); super.component.OriginalComponent(); } }