docs: @SneakyThrows
      public static Resource prepareClasspathResourceIfNeeded(final Resource resource,
                                                              final boolean isDirectory,
                                                              final String containsName) {
          LOGGER.trace("Preparing possible classpath resource [{}]", resource);
          if (resource == null) {
              LOGGER.debug("No resource defined to prepare. Returning null");
              return null;
          }
  
          if (org.springframework.util.ResourceUtils.isFileURL(resource.getURL())) {
              return resource;
          }
  
          val url = org.springframework.util.ResourceUtils.extractArchiveURL(resource.getURL());
          val file = org.springframework.util.ResourceUtils.getFile(url);
  
          val casDirectory = new File(FileUtils.getTempDirectory(), "cas");
          val destination = new File(casDirectory, resource.getFilename());
          if (isDirectory) {
              LOGGER.trace("Creating resource directory [{}]", destination);
              FileUtils.forceMkdir(destination);
              FileUtils.cleanDirectory(destination);
          } else if (destination.exists()) {
              LOGGER.trace("Deleting resource directory [{}]", destination);
              FileUtils.forceDelete(destination);
          }
  
          LOGGER.trace("Processing file [{}]", file);
          try (val jFile = new JarFile(file)) {
              val e = jFile.entries();
              while (e.hasMoreElements()) {
                  val entry = e.nextElement();
                  val name = entry.getName();
                  LOGGER.trace("Comparing [{}] against [{}] and pattern [{}]", name, resource.getFilename(), containsName);
                  if (name.contains(resource.getFilename()) && RegexUtils.find(containsName, name)) {
                      try (val stream = jFile.getInputStream(entry)) {
                          var copyDestination = destination;
                          if (isDirectory) {
                              val entryFileName = new File(name);
                              copyDestination = new File(destination, entryFileName.getName());
                          }
                          LOGGER.trace("Copying resource entry [{}] to [{}]", name, copyDestination);
                          try (val writer = Files.newBufferedWriter(copyDestination.toPath(), StandardCharsets.UTF_8)) {
                              IOUtils.copy(stream, writer, StandardCharsets.UTF_8);
                          }
                      }
                  }
              }
          }
          return new FileSystemResource(destination);
      }