For a school report I have to explain how the java.io.Reader package implements the Decorator pattern. I have seen multiple explanations for the java.io package (here for example) but not for the java.io.Reader package (if that's even any different). Here is what I have now, I know this design doesn't show it correctly, but I am not sure how the java.io.Reader package actually does implement it.
So in this case the Reader
would be the Component
, the InputStreamReader
the Concrete Component
, the BufferedReader
the Decorator
and the LineNumberReader
the Concrete Decorator
. Again, I know this is wrong but I don't know how to correctly display it.
The diagram is correct. If you have access to Intellij (or other capable tool) you can see the UML class diagram for Java types. The below snippet is one such diagram.
As you can see, it agrees with yours. One thing I would consider though is BufferedReader
a concrete decorator since it provides additional behavior on Reader
.