Package jenkins.scm.api.trait
Class SCMSourceContext<C extends SCMSourceContext<C,R>,R extends SCMSourceRequest>
java.lang.Object
jenkins.scm.api.trait.SCMSourceContext<C,R>
- Type Parameters:
C
- the type ofSCMSourceContext
R
- the type ofSCMSourceRequest
produced by this context.
public abstract class SCMSourceContext<C extends SCMSourceContext<C,R>,R extends SCMSourceRequest>
extends Object
Represents the context within which a
SCMSource
is processing requests. In general this is used as a builder
for SCMSourceRequest
instances through newRequest(SCMSource, TaskListener)
but there
are some cases (such as SCMHeadEvent
processing) where only the context is required and as such this
type will be instantiated to obtain the context but no SCMSourceRequest
will be created. Conventions:
- The context is not designed to be shared by multiple threads.
- All methods should be either
final
orabstract
unless there is a documented reason for allowing overrides - All "setter" methods will return
SCMSourceContext
and be called "withXxx" - All "getter" methods will be called "xxx()". Callers should not assume that the returned value is resistant
from concurrent changes. Implementations should ensure that the returned value is immutable by the caller.
In other words, it is intentional for implementations to reduce intermediate allocations by
return Collections.unmodifiableList(theList);
rather than the concurrency safereturn Collections.unmodifiableList(new ArrayList<>(theList));
- Since:
- 2.2.0
-
Constructor Summary
ConstructorDescriptionSCMSourceContext
(SCMSourceCriteria criteria, SCMHeadObserver observer) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal List<SCMHeadAuthority<?,
?, ?>> Returns the (possibly empty) list ofSCMHeadAuthority
instances that can define trust.final List<SCMSourceCriteria>
criteria()
Returns the (possibly empty) list of criteria that must be met by a candidateSCMHead
.final List<SCMHeadFilter>
filters()
Returns the (possibly empty) list ofSCMSourceRequest
dependent filters.abstract R
newRequest
(SCMSource source, TaskListener listener) Creates a newSCMSourceRequest
.final SCMHeadObserver
observer()
Returns theSCMHeadObserver
.final List<SCMHeadPrefilter>
Returns the (possibly empty) list ofSCMSourceRequest
independent pre-filters.final C
withAuthority
(SCMHeadAuthority authority) Adds an additionalSCMHeadAuthority
.final C
withCriteria
(SCMSourceCriteria criteria) Adds an additionalSCMSourceCriteria
.final C
withFilter
(SCMHeadFilter filter) Adds an additionalSCMHeadFilter
.final C
withPrefilter
(SCMHeadPrefilter prefilter) Adds an additionalSCMHeadPrefilter
.final C
withTrait
(SCMSourceTrait trait) Adds an additionalSCMSourceTrait
.final C
withTraits
(Collection<SCMSourceTrait> traits) Adds additionalSCMSourceTrait
s.final C
withTraits
(SCMSourceTrait... traits) Adds additionalSCMSourceTrait
s.
-
Constructor Details
-
SCMSourceContext
public SCMSourceContext(@CheckForNull SCMSourceCriteria criteria, @NonNull SCMHeadObserver observer) Constructor.- Parameters:
criteria
- (optional) criteria.observer
- theSCMHeadObserver
.
-
-
Method Details
-
authorities
Returns the (possibly empty) list ofSCMHeadAuthority
instances that can define trust.- Returns:
- the (possibly empty) list of
SCMHeadAuthority
instances that can define trust.
-
criteria
Returns the (possibly empty) list of criteria that must be met by a candidateSCMHead
.- Returns:
- the (possibly empty) list of criteria that must be met by a candidate
SCMHead
.
-
filters
Returns the (possibly empty) list ofSCMSourceRequest
dependent filters.- Returns:
- the (possibly empty) list of
SCMSourceRequest
dependent filters.
-
prefilters
Returns the (possibly empty) list ofSCMSourceRequest
independent pre-filters.- Returns:
- the (possibly empty) list of
SCMSourceRequest
independent pre-filters.
-
observer
Returns theSCMHeadObserver
.- Returns:
- the
SCMHeadObserver
.
-
withAuthority
Adds an additionalSCMHeadAuthority
.- Parameters:
authority
- theSCMHeadAuthority
.- Returns:
this
for method chaining.
-
withCriteria
Adds an additionalSCMSourceCriteria
.- Parameters:
criteria
- theSCMSourceCriteria
.- Returns:
this
for method chaining.
-
withFilter
Adds an additionalSCMHeadFilter
.- Parameters:
filter
- theSCMHeadFilter
.- Returns:
this
for method chaining.
-
withPrefilter
Adds an additionalSCMHeadPrefilter
.- Parameters:
prefilter
- theSCMHeadPrefilter
.- Returns:
this
for method chaining.
-
withTrait
Adds an additionalSCMSourceTrait
.- Parameters:
trait
- theSCMSourceTrait
.- Returns:
this
for method chaining.
-
withTraits
Adds additionalSCMSourceTrait
s.- Parameters:
traits
- theSCMSourceTrait
s.- Returns:
this
for method chaining.
-
withTraits
Adds additionalSCMSourceTrait
s.- Parameters:
traits
- theSCMSourceTrait
s.- Returns:
this
for method chaining.
-
newRequest
@NonNull public abstract R newRequest(@NonNull SCMSource source, @CheckForNull TaskListener listener) Creates a newSCMSourceRequest
.- Parameters:
source
- theSCMSource
.listener
- the (optional)TaskListener
.- Returns:
- the
SCMSourceContext
-