Interface Configurator<T>

All Known Subinterfaces:
RootElementConfigurator<T>
All Known Implementing Classes:
AdminWhitelistRuleConfigurator, BaseConfigurator, ConfigurableConfigurator, DataBoundConfigurator, DescriptorConfigurator, EnumConfigurator, ExtensionConfigurator, GlobalConfigurationCategoryConfigurator, HeteroDescribableConfigurator, HudsonPrivateSecurityRealmConfigurator, JenkinsConfigurator, JNLPLauncherConfigurator, LabelAtomConfigurator, LabelAtomPropertyConfigurator, MavenConfigurator, NoneSecurityRealmConfigurator, PrimitiveConfigurator, SelfConfigurator, UnsecuredAuthorizationStrategyConfigurator, UpdateCenterConfigurator, UpdateSiteConfigurator

public interface Configurator<T>
Define a Configurator which handles a configuration element, identified by name.
Author:
Nicolas De Loof, Oleg Nenashev
See Also:
  • Method Details

    • normalize

      @NonNull static String normalize(@NonNull String name)
    • getName

      @NonNull default String getName()
      Get a configurator name. This should return the default name for the configurator, used for exporting yaml see getNames() for all possible names which will be considered when configuring.
      Returns:
      short name for this component when used in a configuration.yaml file
    • getNames

      @NonNull default List<String> getNames()
      Get all possible configurator names
      Returns:
      a list of all possible short names for this component when used in a configuration.yaml file
    • getDisplayName

      default String getDisplayName()
      Returns:
      Human friendly display name for this component, used in generated documentation.
    • getTarget

      Class<T> getTarget()
      Target type this configurator can handle.
    • canConfigure

      default boolean canConfigure(Class clazz)
      Returns:
      true if this configurator can handle type clazz. Implementation has to be consistent with getTarget()
    • getImplementedAPI

      @NonNull default Class getImplementedAPI()
      Returns:
      The API implemented by target type, i.e. implemented ExtensionPoint for components to implement some jenkins APIs, or raw type for others.
    • getConfigurators

      @NonNull default List<Configurator<T>> getConfigurators(ConfigurationContext context)
      Returns:
      list of Configurators to be considered so one can fully configure this component. Typically, configurator for an abstract extension point will return Configurators for available implementations.
    • describe

      @NonNull Set<Attribute<T,?>> describe()
      Determine the list of Attribute available for configuration of the managed component.
      Returns:
      A set of Attributes that describes this object
    • getAttributes

      @NonNull default List<Attribute<T,?>> getAttributes()
      Returns:
      Ordered version of describe() for documentation generation. Only include non-ignored attribute
    • configure

      @NonNull T configure(CNode config, ConfigurationContext context) throws ConfiguratorException
      Configures/creates a Jenkins object based on a tree.
      Parameters:
      config - Map/List/primitive objects (think YAML) that represents the configuration from which a Jenkins object is configured.
      context - Fully configured Jenkins object used as the starting point for this configuration.
      Returns:
      Fully configured Jenkins object that results from this configuration. if no new objects got created, but some existing objects may have been modified, return updated target object.
      Throws:
      ConfiguratorException - if something went wrong, depends on the concrete implementation
    • check

      T check(CNode config, ConfigurationContext context) throws ConfiguratorException
      Run the same logic as configure(CNode, ConfigurationContext) in dry-run mode. Used to verify configuration is fine before being actually applied to a live jenkins controller.
      Parameters:
      config - Map/List/primitive objects (think YAML) that represents the configuration from which a Jenkins object is configured.
      context - Fully configured Jenkins object used as the starting point for this configuration.
      Throws:
      ConfiguratorException - on configuration error
    • describe

      @CheckForNull default CNode describe(T instance, ConfigurationContext context) throws Exception
      Describe a component as a Configuration Nodes CNode to be exported as yaml. Only export attributes which are not set to default value.
      Throws:
      Exception
    • describeStructure

      @CheckForNull default CNode describeStructure(T instance, ConfigurationContext context)
      Describe Structure of the attributes, as required by the schema.
      Parameters:
      instance - Object whose attributes will be described.
      context - Fully configured Jenkins object used as the starting point for this configuration.
      Returns:
      CNode describing the attributes.
      Since:
      1.35
    • extractExtensionOrdinal

      static double extractExtensionOrdinal(Object obj)
    • extractExtensionOrdinal

      static double extractExtensionOrdinal(Attribute<?,?> attribute)
    • extractExtensionOrdinal

      static double extractExtensionOrdinal(Class clazz)
    • extensionOrdinalSort

      static Comparator<Object> extensionOrdinalSort()