content: interface ILightningPhone {
      void recharge();
      void useLightning();
  }
  
  interface IMicroUsbPhone {
      void recharge();
      void useMicroUsb();
  }
  
  class Iphone implements ILightningPhone {
      private boolean connector;
  
      @Override
      public void useLightning() {
          connector = true;
          System.out.println("Lightning connected");
      }
  
      @Override
      public void recharge() {
          if (connector) {
              System.out.println("Recharge started");
              System.out.println("Recharge finished");
          } else {
              System.out.println("Connect Lightning first");
          }
      }
  }
  
  class Android implements IMicroUsbPhone {
      private boolean connector;
  
      @Override
      public void useMicroUsb() {
          connector = true;
          System.out.println("MicroUsb connected");
      }
  
      @Override
      public void recharge() {
          if (connector) {
              System.out.println("Recharge started");
              System.out.println("Recharge finished");
          } else {
              System.out.println("Connect MicroUsb first");
          }
      }
  }
  /* exposing the target interface while wrapping source object */
  class LightningToMicroUsbAdapter implements IMicroUsbPhone {
      private final ILightningPhone lightningPhone;
  
      public LightningToMicroUsbAdapter(ILightningPhone lightningPhone) {
          this.lightningPhone = lightningPhone;
      }
  
      @Override
      public void useMicroUsb() {
          System.out.println("MicroUsb connected");
          lightningPhone.useLightning();
      }
  
      @Override
      public void recharge() {
          lightningPhone.recharge();
      }
  }
  
  public class AdapterPattern {
      static void rechargeMicroUsbPhone(IMicroUsbPhone phone) {
          phone.useMicroUsb();
          phone.recharge();
      }
  
      static void rechargeLightningPhone(ILightningPhone phone) {
          phone.useLightning();
          phone.recharge();
      }
  
      public static void main(String[] args) {
          Android android = new Android();
          Iphone iPhone = new Iphone();
  
          System.out.println("Recharging android with MicroUsb");
          rechargeMicroUsbPhone(android);
  
          System.out.println("Recharging iPhone with Lightning");
          rechargeLightningPhone(iPhone);
  
          System.out.println("Recharging iPhone with MicroUsb");
          rechargeMicroUsbPhone(new LightningToMicroUsbAdapter (iPhone));
      }
  }
  