Compare Extension Object and Decorator in Java so optional capabilities and wrapper-based behavior layering are not confused.
Extension Object and Decorator both deal with optional functionality, but they do it differently.
Decorator wraps an object and preserves the same contract while adding behavior around it.
Extension Object exposes additional capabilities through separate types that may or may not be present.
Ask:
DecoratorExtension ObjectThat difference matters.