Class ToolNameRegistry

java.lang.Object
io.jenkins.plugins.analysis.core.model.ToolNameRegistry

public class ToolNameRegistry extends Object
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 Details

    • ToolNameRegistry

      public ToolNameRegistry()
      Creates an empty registry.
    • ToolNameRegistry

      public ToolNameRegistry(Map<String,String> idToNameMap)
      Creates a registry with the given ID-to-name mapping.
      Parameters:
      idToNameMap - the mapping of tool IDs to names
  • Method Details

    • fromBuild

      public static ToolNameRegistry fromBuild(Run<?,?> build)
      Creates a registry from the ResultActions 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

      public String getName(String id)
      Returns the human-readable name for a tool ID. If the ID is not registered, attempts to look up the name from the LabelProviderFactory. 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

      public void register(String id, String name)
      Registers a tool ID with its corresponding name. The name will be HTML-escaped before storing.
      Parameters:
      id - the tool ID
      name - the human-readable name
    • contains

      public boolean contains(String id)
      Returns whether the registry contains a mapping for the given tool ID.
      Parameters:
      id - the tool ID
      Returns:
      true if the registry contains a mapping for the ID, false otherwise
    • size

      public int size()
      Returns the number of registered tool IDs.
      Returns:
      the number of registered IDs
    • asMap

      public Map<String,String> 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