Class ChildLoader
java.lang.Object
com.cloudbees.hudson.plugins.folder.ChildLoader
- All Implemented Interfaces:
ExtensionPoint
- Direct Known Subclasses:
DefaultChildLoader
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <V extends TopLevelItem>
booleanensureDirExists(File modulesDir, AbstractFolder<V> parent) Ensure that the specified directory exists.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.protected abstract <K,V extends TopLevelItem>
Map<K,V> loadChildren(AbstractFolder<V> parent, File modulesDir, Function<? super V, ? extends K> key) Loads all the childItems.<V extends TopLevelItem>
VloadItem(AbstractFolder<V> parent, File subdir, V item) Load aTopLevelItemfrom a given directory.
-
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 childItems.- Type Parameters:
K- the key typeV- 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 createdparent- parent folder associated with the directory- Returns:
trueif the directory exists or was successfully created;falseotherwise
-
getItemsByDirName
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 aTopLevelItemfrom 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 itemsubdir- the directory from which the item configuration can potentially be loadeditem- 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
nullif an error occurs during loading
-