Class ToolNameRegistry
java.lang.Object
io.jenkins.plugins.analysis.core.model.ToolNameRegistry
Registry that maps tool IDs to their human-readable names. This is used to display tool names instead of IDs in
trend charts and other visualizations.
- Author:
- Akash Manna
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty registry.ToolNameRegistry(Map<String, String> idToNameMap) Creates a registry with the given ID-to-name mapping. -
Method Summary
Modifier and TypeMethodDescriptionasMap()Returns the ID-to-name mapping as an immutable map.booleanReturns whether the registry contains a mapping for the given tool ID.static ToolNameRegistryCreates a registry from theResultActions of a build.Returns the human-readable name for a tool ID.voidRegisters a tool ID with its corresponding name.intsize()Returns the number of registered tool IDs.
-
Constructor Details
-
ToolNameRegistry
public ToolNameRegistry()Creates an empty registry. -
ToolNameRegistry
Creates a registry with the given ID-to-name mapping.- Parameters:
idToNameMap- the mapping of tool IDs to names
-
-
Method Details
-
fromBuild
Creates a registry from theResultActions of a build. Each action provides a tool ID and name, which are stored in the registry for later lookup. Names are HTML-escaped at creation time.- Parameters:
build- the build that contains the result actions- Returns:
- a registry containing all tool IDs and HTML-escaped names from the build
-
getName
Returns the human-readable name for a tool ID. If the ID is not registered, attempts to look up the name from theLabelProviderFactory. If that also fails, returns the ID itself. Names returned are already HTML-escaped.- Parameters:
id- the tool ID- Returns:
- the HTML-escaped human-readable name, or the escaped ID if no name is found
-
register
Registers a tool ID with its corresponding name. The name will be HTML-escaped before storing.- Parameters:
id- the tool IDname- the human-readable name
-
contains
Returns whether the registry contains a mapping for the given tool ID.- Parameters:
id- the tool ID- Returns:
trueif the registry contains a mapping for the ID,falseotherwise
-
size
public int size()Returns the number of registered tool IDs.- Returns:
- the number of registered IDs
-
asMap
Returns the ID-to-name mapping as an immutable map. The names in the returned map are already HTML-escaped.- Returns:
- an immutable map from tool IDs to HTML-escaped names
-