Class Adapter

java.lang.Object
Structural.Adapter.Adapter
All Implemented Interfaces:
Target

public class Adapter extends Object implements Target
The Adapter class makes the Adaptee compatible with the Target interface. The Adapter implements the Target interface and translates calls from the client to the Adaptee's methods. This enables the client to work seamlessly with Adaptee without being aware of its specific implementation.
  • Constructor Details

    • Adapter

      public Adapter(Adaptee adaptee)
      Constructs the Adapter with an Adaptee instance.
      Parameters:
      adaptee - The Adaptee instance to adapt.
      Throws:
      IllegalArgumentException - if the adaptee is null.
  • Method Details

    • request

      public String request()
      Implements the Target interface by delegating to the Adaptee. This method translates the Target's `request()` call into a call to the Adaptee's `specificRequest()` method.
      Specified by:
      request in interface Target
      Returns:
      A string response translated by the Adapter.