Design pattern that Wrapper Classes use in Java?

zack picture zack · Nov 15, 2018 · Viewed 8.9k times · Source

I have found an old post which does not clarify my understanding about the design patterns that are used by Wrapper Classes, Moreover, on reading from Wikipedia I'm not getting any clear information.

Does a Wrapper Class really use any design pattern or not?

If it is using a pattern, then which pattern is it out of these: Decorator Pattern, Facade Pattern or Adapter Pattern?

Answer

user7294900 picture user7294900 · Nov 15, 2018

If you refer to wrapping primitive

Wrapper classes provide a way to use primitive types as objects

Adapter pattern is the most exact meaning:

A decorator makes it possible to add or alter behavior of an interface at run-time. Alternatively, the adapter can be used when the wrapper must respect a particular interface and must support polymorphic behavior, and the Facade when an easier or simpler interface to an underlying object is desired

We use Wrapper class ability to use primitive as Objects, meaning add support to a polymorphic behavior