code: @Override
      public final Class<? extends T> enhanceClass(Class<T> baseClass) {
          logger.info("Enhancing {}", baseClass);
  
          CtClass original = null;
  
          try {
              original = pool.get(baseClass.getName());
  
              TemplateHelper templateHelper = new TemplateHelper(pool);
              VelocityContext velocityContext = new VelocityContext();
  
              velocityContext.put("_", templateHelper);
              velocityContext.put("base", original);
              velocityContext.put("getters", findGetters(original));
              velocityContext.put("abstractMethods", findAbstractMethods(original));
  
              Map<String, Object> contextItems = getAdditionalContextItems();
  
              for (Map.Entry<String, Object> contextItem : contextItems.entrySet()) {
                  velocityContext.put(contextItem.getKey(), contextItem.getValue());
              }
  
              StringWriter writer = new StringWriter();
              engine.getTemplate(getTemplateLocation()).merge(velocityContext, writer);
  
              logger.debug("Enhanced {} to form new class {} with source:\n{}",
                           baseClass.getSimpleName(), templateHelper.clsName(), writer);
  
              return ClassLoadingUtil.toClass(templateHelper.compile());
          } catch (Exception e) {
              logger.error("An error occurred while enhancing {}", baseClass);
  
              throw ExceptionUtil.propagate(e);
          } finally {
              if (original != null) {
                  original.detach();
              }
          }
      }
docs: -------------------------------------------------------------