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 ofSCMSourceContextR- the type ofSCMSourceRequestproduced 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
finalorabstractunless there is a documented reason for allowing overrides - All "setter" methods will return
SCMSourceContextand 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
ConstructorsConstructorDescriptionSCMSourceContext(SCMSourceCriteria criteria, SCMHeadObserver observer) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal List<SCMHeadAuthority<?,?, ?>> Returns the (possibly empty) list ofSCMHeadAuthorityinstances 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 ofSCMSourceRequestdependent filters.abstract RnewRequest(SCMSource source, TaskListener listener) Creates a newSCMSourceRequest.final SCMHeadObserverobserver()Returns theSCMHeadObserver.final List<SCMHeadPrefilter>Returns the (possibly empty) list ofSCMSourceRequestindependent pre-filters.final CwithAuthority(SCMHeadAuthority authority) Adds an additionalSCMHeadAuthority.final CwithCriteria(SCMSourceCriteria criteria) Adds an additionalSCMSourceCriteria.final CwithFilter(SCMHeadFilter filter) Adds an additionalSCMHeadFilter.final CwithPrefilter(SCMHeadPrefilter prefilter) Adds an additionalSCMHeadPrefilter.final CwithTrait(SCMSourceTrait trait) Adds an additionalSCMSourceTrait.final CwithTraits(Collection<SCMSourceTrait> traits) Adds additionalSCMSourceTraits.final CwithTraits(SCMSourceTrait... traits) Adds additionalSCMSourceTraits.
-
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 ofSCMHeadAuthorityinstances that can define trust.- Returns:
- the (possibly empty) list of
SCMHeadAuthorityinstances 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 ofSCMSourceRequestdependent filters.- Returns:
- the (possibly empty) list of
SCMSourceRequestdependent filters.
-
prefilters
Returns the (possibly empty) list ofSCMSourceRequestindependent pre-filters.- Returns:
- the (possibly empty) list of
SCMSourceRequestindependent pre-filters.
-
observer
Returns theSCMHeadObserver.- Returns:
- the
SCMHeadObserver.
-
withAuthority
Adds an additionalSCMHeadAuthority.- Parameters:
authority- theSCMHeadAuthority.- Returns:
thisfor method chaining.
-
withCriteria
Adds an additionalSCMSourceCriteria.- Parameters:
criteria- theSCMSourceCriteria.- Returns:
thisfor method chaining.
-
withFilter
Adds an additionalSCMHeadFilter.- Parameters:
filter- theSCMHeadFilter.- Returns:
thisfor method chaining.
-
withPrefilter
Adds an additionalSCMHeadPrefilter.- Parameters:
prefilter- theSCMHeadPrefilter.- Returns:
thisfor method chaining.
-
withTrait
Adds an additionalSCMSourceTrait.- Parameters:
trait- theSCMSourceTrait.- Returns:
thisfor method chaining.
-
withTraits
Adds additionalSCMSourceTraits.- Parameters:
traits- theSCMSourceTraits.- Returns:
thisfor method chaining.
-
withTraits
Adds additionalSCMSourceTraits.- Parameters:
traits- theSCMSourceTraits.- Returns:
thisfor 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
-