Class ChildLoader

java.lang.Object
com.cloudbees.hudson.plugins.folder.ChildLoader
All Implemented Interfaces:
ExtensionPoint
Direct Known Subclasses:
DefaultChildLoader

public abstract class ChildLoader extends Object implements ExtensionPoint
  • Constructor Details

    • ChildLoader

      public ChildLoader()
  • Method Details

    • loadChildren

      protected abstract <K, V extends TopLevelItem> Map<K,V> loadChildren(AbstractFolder<V> parent, File modulesDir, Function<? super V,? extends K> key)
      Loads all the child Items.
      Type Parameters:
      K - the key type
      V - the child type.
      Parameters:
      parent - the parent of the children.
      modulesDir - Directory that contains sub-directories for each child item.
      key - the key generating function.
      Returns:
      a map of the children keyed by the generated keys.
    • ensureDirExists

      protected <V extends TopLevelItem> boolean ensureDirExists(File modulesDir, AbstractFolder<V> parent)
      Ensure that the specified directory exists. If the directory does not exist, attempt to create it.
      Parameters:
      modulesDir - the directory that should exist or needs to be created
      parent - parent folder associated with the directory
      Returns:
      true if the directory exists or was successfully created; false otherwise
    • getItemsByDirName

      protected <V extends TopLevelItem> Map<String,V> getItemsByDirName(AbstractFolder<V> parent)
      Retrieve a map of items contained within a specified parent folder, keyed by their directory names.
      Parameters:
      parent - the parent folder containing the items
      Returns:
      a map where the keys are the directory names of the items and the values are the items themselves
    • loadItem

      @CheckForNull public <V extends TopLevelItem> V loadItem(AbstractFolder<V> parent, File subdir, @CheckForNull V item)
      Load a TopLevelItem from a given directory. The method attempts to read the item configuration, assign an appropriate name to the item, and initialize it within the provided parent folder.
      Parameters:
      parent - the parent folder that will contain the loaded item
      subdir - the directory from which the item configuration can potentially be loaded
      item - an optional pre-existing item that can be reused; if null, the item will be loaded from the directory
      Returns:
      the loaded item if successful, or null if an error occurs during loading