Package jenkins.scm.api
Class SCMSourceDescriptor
- java.lang.Object
-
- hudson.model.Descriptor<SCMSource>
-
- jenkins.scm.api.SCMSourceDescriptor
-
- Direct Known Subclasses:
SingleSCMSource.DescriptorImpl
public abstract class SCMSourceDescriptor extends Descriptor<SCMSource> implements IconSpec
ADescriptor
forSCMSource
s.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class hudson.model.Descriptor
Descriptor.FormException, Descriptor.PropertyType, Descriptor.Self
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<SCMHeadCategory>
categories
The set ofSCMHeadCategory
singletons for this type ofSCMSource
-
Fields inherited from class hudson.model.Descriptor
clazz
-
-
Constructor Summary
Constructors Constructor Description SCMSourceDescriptor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SCMHeadCategory[]
createCategories()
Creates the singletonSCMHeadCategory
instances that this type ofSCMSource
is capable of producing.static List<SCMSourceDescriptor>
forOwner(Class<? extends SCMSourceOwner> clazz)
Returns the list of descriptors that are appropriate for a specified type of owner andisUserInstantiable()
.static List<SCMSourceDescriptor>
forOwner(Class<? extends SCMSourceOwner> clazz, boolean onlyUserInstantiable)
Returns the list of descriptors that are appropriate for a specified type of owner with the additional filter byisUserInstantiable()
.static List<SCMSourceDescriptor>
forOwner(SCMSourceOwner owner)
Returns the list of descriptors that are appropriate for a specified owner andisUserInstantiable()
.static List<SCMSourceDescriptor>
forOwner(SCMSourceOwner owner, boolean onlyUserInstantiable)
Returns the list of descriptors that are appropriate for a specified owner with the additional filter byisUserInstantiable()
.Set<SCMHeadCategory>
getCategories()
Returns the set ofSCMHeadCategory
that thisSCMSource
supports.String
getIconClassName()
Used to categorize this kind ofSCMSource
String
getId(SCMSource source)
Return or generate the ID for a source instance.String
getPronoun()
Get the term used in the UI to represent this kind ofSCMSource
.List<SCMSourceTrait>
getTraitsDefaults()
Returns the default traits for thisSCMSource
.boolean
isApplicable(Class<? extends SCMSourceOwner> owner)
Returnstrue
if this source type is applicable to the given owner.boolean
isUserInstantiable()
Returnstrue
if the source type is one that the user is permitted to configure.-
Methods inherited from class hudson.model.Descriptor
addHelpFileRedirect, bindJSON, calcAutoCompleteSettings, calcFillSettings, configure, configure, doHelp, find, find, findByDescribableClassName, findById, getCategory, getCheckMethod, getCheckUrl, getConfigFile, getConfigPage, getCurrentDescriptorByNameUrl, getDescriptorFullUrl, getDescriptorUrl, getDisplayName, getGlobalConfigPage, getGlobalPropertyType, getHelpFile, getHelpFile, getHelpFile, getId, getJsonSafeClassName, getKlass, getPlugin, getPossibleViewNames, getPropertyType, getPropertyType, getPropertyTypeOrDie, getRequiredGlobalConfigPagePermission, getT, getViewPage, isInstance, isSubTypeOf, load, newInstance, newInstance, newInstancesFromHeteroList, newInstancesFromHeteroList, save, self, toArray, toList, toMap
-
-
-
-
Field Detail
-
categories
protected transient Set<SCMHeadCategory> categories
The set ofSCMHeadCategory
singletons for this type ofSCMSource
- Since:
- 2.0
- See Also:
getCategories()
-
-
Method Detail
-
getId
@NonNull public String getId(@CheckForNull SCMSource source)
Return or generate the ID for a source instance.- Parameters:
source
- the source ornull
if a new source.- Returns:
- the ID of the supplied source or a newly generated ID to use for a new source instance.
-
isApplicable
public boolean isApplicable(Class<? extends SCMSourceOwner> owner)
Returnstrue
if this source type is applicable to the given owner.- Parameters:
owner
- the type of owner.- Returns:
- true to allow user to select and configure this source.
-
isUserInstantiable
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isUserInstantiable()
Returnstrue
if the source type is one that the user is permitted to configure. Where a source is used to wrap or decorate another source it may make sense to returnfalse
.- Returns:
true
if the source type is one that the user is permitted to configure via the UI.
-
getTraitsDefaults
@NonNull public List<SCMSourceTrait> getTraitsDefaults()
Returns the default traits for thisSCMSource
.- Returns:
- An empty list if not overridden.
-
forOwner
@NonNull public static List<SCMSourceDescriptor> forOwner(@CheckForNull SCMSourceOwner owner)
Returns the list of descriptors that are appropriate for a specified owner andisUserInstantiable()
.- Parameters:
owner
- the owner.- Returns:
- the list of descriptors
-
forOwner
@NonNull public static List<SCMSourceDescriptor> forOwner(@CheckForNull SCMSourceOwner owner, boolean onlyUserInstantiable)
Returns the list of descriptors that are appropriate for a specified owner with the additional filter byisUserInstantiable()
.- Parameters:
owner
- the owner.onlyUserInstantiable
-true
if only those descriptors that areisUserInstantiable()
.- Returns:
- the list of descriptors
-
forOwner
@NonNull public static List<SCMSourceDescriptor> forOwner(Class<? extends SCMSourceOwner> clazz)
Returns the list of descriptors that are appropriate for a specified type of owner andisUserInstantiable()
.- Parameters:
clazz
- the type of owner.- Returns:
- the list of descriptors
-
forOwner
@NonNull public static List<SCMSourceDescriptor> forOwner(Class<? extends SCMSourceOwner> clazz, boolean onlyUserInstantiable)
Returns the list of descriptors that are appropriate for a specified type of owner with the additional filter byisUserInstantiable()
.- Parameters:
clazz
- the type of owner.onlyUserInstantiable
-true
if only those descriptors that areisUserInstantiable()
.- Returns:
- the list of descriptors
-
getIconClassName
public String getIconClassName()
Used to categorize this kind ofSCMSource
- Specified by:
getIconClassName
in interfaceIconSpec
- Returns:
- The Icon class specification e.g. 'icon-notepad'.
-
getPronoun
@CheckForNull public String getPronoun()
Get the term used in the UI to represent this kind ofSCMSource
. Must start with a capital letter.- Returns:
- the term or
null
to fall back to the calling context's default. - Since:
- 2.0
-
getCategories
@NonNull public final Set<SCMHeadCategory> getCategories()
Returns the set ofSCMHeadCategory
that thisSCMSource
supports. There will always be exactly oneSCMCategory.isUncategorized()
instance in the returned set.- Returns:
- the set of
SCMHeadCategory
that thisSCMSource
supports. - Since:
- 2.0
-
createCategories
@NonNull protected SCMHeadCategory[] createCategories()
Creates the singletonSCMHeadCategory
instances that this type ofSCMSource
is capable of producing.- Returns:
- the singleton
SCMHeadCategory
instances for this type ofSCMSource
- Since:
- 2.0
- See Also:
getCategories()
-
-