Package jenkins.scm.api.trait
Class SCMSourceTrait
- All Implemented Interfaces:
ExtensionPoint
,Describable<SCMSourceTrait>
- Direct Known Subclasses:
RegexSCMHeadFilterTrait
,WildcardSCMHeadFilterTrait
Represents a trait of behaviour or configuration that can be applied to a
SCMSource
.- Since:
- 2.2.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<SCMSourceTraitDescriptor>
_for
(Class<? extends SCMSourceContext> contextClass, Class<? extends SCMBuilder> builderClass) Returns the subset ofSCMSourceTraitDescriptor
instances that are applicable to the specified types ofSCMSourceContext
andSCMSourceBuilder
.static List<SCMSourceTraitDescriptor>
_for
(SCMSourceDescriptor scmSource, Class<? extends SCMSourceContext> contextClass, Class<? extends SCMBuilder> builderClass) Returns the subset ofSCMSourceTraitDescriptor
instances that are applicable to the specifiedSCMSourceDescriptor
and specified types ofSCMNavigatorContext
andSCMSourceBuilder
.all()
Returns all theSCMSourceTraitDescriptor
instances.final void
applyToBuilder
(SCMBuilder<?, ?> builder) Applies this trait to theSCMBuilder
.final void
applyToContext
(SCMSourceContext<?, ?> context) Applies this trait to theSCMSourceContext
.final SCMHeadObserver
applyToObserver
(SCMHeadObserver observer) Applies this trait to an observer for use during aSCMSourceRequest
.protected void
decorateBuilder
(SCMBuilder<?, ?> builder) SPI: Override this method to decorate aSCMBuilder
.protected void
decorateContext
(SCMSourceContext<?, ?> context) SPI: Override this method to decorate aSCMSourceContext
.protected SCMHeadObserver
decorateObserver
(SCMHeadObserver observer) SPI: Override this method to decorate theSCMHeadObserver
used during aSCMSourceRequest
.protected boolean
includeCategory
(SCMHeadCategory category) SPI: Override this method to control whether specificSCMHeadCategory
instances are required.final boolean
isCategoryEnabled
(SCMHeadCategory category) Checks if the supplied category is required by this trait.
-
Constructor Details
-
SCMSourceTrait
public SCMSourceTrait()
-
-
Method Details
-
applyToContext
Applies this trait to theSCMSourceContext
.- Parameters:
context
- the context.
-
decorateContext
SPI: Override this method to decorate aSCMSourceContext
. You can assume that yourSCMSourceTraitDescriptor.isApplicableToContext(Class)
istrue
within this method and that the provided context is an instance ofSCMSourceTraitDescriptor.getContextClass()
.- Parameters:
context
- the context (invariant:SCMSourceTraitDescriptor.isApplicableToContext(Class)
istrue
andSCMSourceTraitDescriptor.getContextClass()
Class.isInstance(Object)
) istrue
)
-
applyToObserver
Applies this trait to an observer for use during aSCMSourceRequest
.- Parameters:
observer
- the observer.- Returns:
- the supplied observer or a wrapped variant of it.
-
decorateObserver
SPI: Override this method to decorate theSCMHeadObserver
used during aSCMSourceRequest
.- Parameters:
observer
- the observer.- Returns:
- the supplied observer or a wrapped variant of it.
-
applyToBuilder
Applies this trait to theSCMBuilder
.- Parameters:
builder
- the builder.
-
decorateBuilder
SPI: Override this method to decorate aSCMBuilder
. You can assume that yourSCMSourceTraitDescriptor.isApplicableToBuilder(SCMBuilder)
istrue
within this method and that the provided builder is an instance ofSCMSourceTraitDescriptor.getBuilderClass()
.- Parameters:
builder
- the builder (invariant:SCMSourceTraitDescriptor.isApplicableToBuilder(SCMBuilder)
istrue
andSCMSourceTraitDescriptor.getBuilderClass()
Class.isInstance(Object)
) istrue
)
-
isCategoryEnabled
Checks if the supplied category is required by this trait.- Parameters:
category
- the category.- Returns:
true
if this trait requires the supplied category.
-
includeCategory
SPI: Override this method to control whether specificSCMHeadCategory
instances are required.- Parameters:
category
- the category.- Returns:
true
to require the category.
-
getDescriptor
- Specified by:
getDescriptor
in interfaceDescribable<SCMSourceTrait>
- Overrides:
getDescriptor
in classSCMTrait<SCMSourceTrait>
-
all
Returns all theSCMSourceTraitDescriptor
instances.- Returns:
- all the
SCMSourceTraitDescriptor
instances.
-
_for
public static List<SCMSourceTraitDescriptor> _for(@CheckForNull Class<? extends SCMSourceContext> contextClass, @CheckForNull Class<? extends SCMBuilder> builderClass) Returns the subset ofSCMSourceTraitDescriptor
instances that are applicable to the specified types ofSCMSourceContext
andSCMSourceBuilder
.- Parameters:
contextClass
- (optional) type ofSCMSourceContext
.builderClass
- (optional) type ofSCMBuilder
.- Returns:
- the list of matching
SCMSourceTraitDescriptor
instances.
-
_for
public static List<SCMSourceTraitDescriptor> _for(@CheckForNull SCMSourceDescriptor scmSource, @CheckForNull Class<? extends SCMSourceContext> contextClass, @CheckForNull Class<? extends SCMBuilder> builderClass) Returns the subset ofSCMSourceTraitDescriptor
instances that are applicable to the specifiedSCMSourceDescriptor
and specified types ofSCMNavigatorContext
andSCMSourceBuilder
.- Parameters:
scmSource
- (optional)SCMSourceDescriptor
.contextClass
- (optional) type ofSCMSourceContext
.builderClass
- (optional) type ofSCMBuilder
.- Returns:
- the list of matching
SCMSourceTraitDescriptor
instances.
-