Decorator pattern definition

Decorator mode: Dynamically appends new functionality to objects. It is more flexible than inheritance in extending object functionality, and decorator pattern also embodies the open closed principle (OCP)

The code analysis

Code reference gitee.com/y2m/java-de… Modifier folder

Decorator pattern is applied in the JDK

Java’s IO structure, FilterInputStream, is a decorator