Class ParameterSelector

    • Constructor Detail

      • ParameterSelector

        public ParameterSelector()
    • Method Detail

      • isApplicableFor

        public boolean isApplicableFor​(Class<?> clazz)
        Description copied from class: InheritanceSelector
        This method must return true, if the given Class is a valid supertype of the generic class used by your type.

        For example, if your selector handles a specific JobProperty, this method must return true if you encounter a JobProperty.

        This is used to do a fast pre-selection of which selectors to consider for the basic types offered by Jenkins (Properties, BuildSteps, Publishers, etc. pp.).

        Expect to see lots of ClassCastExceptions or your code not even being called, if you violate this.

        Specified by:
        isApplicableFor in class InheritanceSelector<JobProperty<?>>
        Parameters:
        clazz - the type of objects to check
        Returns:
        true, if this selector applies to the given type of objects.
      • getObjectIdentifier

        public String getObjectIdentifier​(JobProperty<?> obj)
        Description copied from class: InheritanceSelector
        This method returns an identifier for the given object. The identifier should be unique, as long as the objects are not the same in terms of inheritance. If they are the same their ID must also be the same.

        One example is parameters. If you have two objects for the parameter with the name "foo", they should get the same ID, because they logically define the same element in terms of inheritance and thus should either be merged or override each other.

        The purpose of this function is that candidates for merges can be identified by looping once through the list and then merging them in pairs or simply selection the last occurring one.

        Specified by:
        getObjectIdentifier in class InheritanceSelector<JobProperty<?>>
        Parameters:
        obj - the object that should be identified.
        Returns:
        an ID that is the same for multiple objects, if they define the same logical entity in terms of inheritance. Otherwise, the ID must be unique - or null, if this selector is not responsible for this object type.
      • handleSingleton

        public JobProperty<?> handleSingleton​(JobProperty<?> jp,
                                              InheritanceProject caller)
        This method is triggered, when a singleton is encountered -- either after everything has been merged or there is only a single value left.
        Specified by:
        handleSingleton in class InheritanceSelector<JobProperty<?>>
        Parameters:
        jp - the object selected to be returned to Jenkins.
        caller - the project for which the inheritance is determined.
        Returns:
        the object that should actually be returned to Jenkins. Do note that it may be part of a list, in which case the returned value replaces the original value.