Package jenkins.scm.api.trait
Class SCMNavigatorContext<C extends SCMNavigatorContext<C,R>,R extends SCMNavigatorRequest>
- java.lang.Object
-
- jenkins.scm.api.trait.SCMNavigatorContext<C,R>
-
- Type Parameters:
C
- the type ofSCMNavigatorContext
R
- the type ofSCMNavigatorRequest
produced by this context.
public abstract class SCMNavigatorContext<C extends SCMNavigatorContext<C,R>,R extends SCMNavigatorRequest> extends Object
Represents the context within which aSCMNavigator
is processing requests. In general this is used as a builder forSCMNavigatorRequest
instances throughnewRequest(SCMNavigator, SCMSourceObserver)
but there are some cases (such asSCMSourceEvent
processing) where only the context is required and as such this type will be instantiated to obtain the context but noSCMNavigatorRequest
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
SCMNavigatorContext
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
Constructors Constructor Description SCMNavigatorContext()
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description List<SCMSourceDecorator<?,?>>
decorators()
Returns the (possibly empty) list ofSCMSourceDecorator
instances to apply to discovered projects.List<SCMSourceFilter>
filters()
Returns the (possibly empty) list ofSCMNavigatorRequest
dependent filters.abstract R
newRequest(SCMNavigator navigator, SCMSourceObserver observer)
Creates a newSCMNavigatorRequest
.List<SCMSourcePrefilter>
prefilters()
Returns the (possibly empty) list ofSCMNavigatorRequest
independent pre-filters.List<SCMSourceTrait>
traits()
Returns the (possibly empty) list ofSCMSourceTrait
instances to apply to discovered projects.C
withDecorator(SCMSourceDecorator<?,?> decorator)
Adds the suppliedSCMSourceDecorator
.C
withDecorators(Collection<? extends SCMSourceDecorator<?,?>> decorators)
Adds the suppliedSCMSourceDecorator
instances.C
withDecorators(SCMSourceDecorator<?,?>... decorators)
Adds the suppliedSCMSourceDecorator
instances.C
withFilter(SCMSourceFilter filter)
Adds the suppliedSCMSourceFilter
.C
withPrefilter(SCMSourcePrefilter prefilter)
Adds the suppliedSCMSourcePrefilter
.C
withTrait(SCMNavigatorTrait trait)
Applies the suppliedSCMNavigatorTrait
.C
withTrait(SCMSourceTrait trait)
Adds the suppliedSCMSourceTrait
.C
withTraits(Collection<? extends SCMTrait<?>> traits)
Adds / applies the suppliedSCMTrait
.C
withTraits(SCMTrait<? extends SCMTrait<?>>... traits)
Adds / applies the suppliedSCMTrait
.
-
-
-
Method Detail
-
decorators
@NonNull public final List<SCMSourceDecorator<?,?>> decorators()
Returns the (possibly empty) list ofSCMSourceDecorator
instances to apply to discovered projects.- Returns:
- the (possibly empty) list of
SCMSourceDecorator
instances to apply to discovered projects.
-
filters
@NonNull public final List<SCMSourceFilter> filters()
Returns the (possibly empty) list ofSCMNavigatorRequest
dependent filters.- Returns:
- the (possibly empty) list of
SCMNavigatorRequest
dependent filters.
-
prefilters
@NonNull public final List<SCMSourcePrefilter> prefilters()
Returns the (possibly empty) list ofSCMNavigatorRequest
independent pre-filters.- Returns:
- the (possibly empty) list of
SCMNavigatorRequest
independent pre-filters.
-
traits
@NonNull public final List<SCMSourceTrait> traits()
Returns the (possibly empty) list ofSCMSourceTrait
instances to apply to discovered projects.- Returns:
- the (possibly empty) list of
SCMSourceTrait
instances to apply to discovered projects.
-
withFilter
@NonNull public final C withFilter(@CheckForNull SCMSourceFilter filter)
Adds the suppliedSCMSourceFilter
.- Parameters:
filter
- the additionalSCMSourceFilter
.- Returns:
this
for method chaining.
-
withPrefilter
@NonNull public final C withPrefilter(@CheckForNull SCMSourcePrefilter prefilter)
Adds the suppliedSCMSourcePrefilter
.- Parameters:
prefilter
- the additionalSCMSourcePrefilter
.- Returns:
this
for method chaining.
-
withTrait
@NonNull public final C withTrait(@NonNull SCMNavigatorTrait trait)
Applies the suppliedSCMNavigatorTrait
.- Parameters:
trait
- the additionalSCMNavigatorTrait
.- Returns:
this
for method chaining.
-
withTrait
@NonNull public final C withTrait(@NonNull SCMSourceTrait trait)
Adds the suppliedSCMSourceTrait
.- Parameters:
trait
- the additionalSCMSourceTrait
.- Returns:
this
for method chaining.
-
withTraits
@NonNull public final C withTraits(@NonNull SCMTrait<? extends SCMTrait<?>>... traits)
Adds / applies the suppliedSCMTrait
.- Parameters:
traits
- the additionalSCMTrait
instances.- Returns:
this
for method chaining.
-
withTraits
@NonNull public final C withTraits(@NonNull Collection<? extends SCMTrait<?>> traits)
Adds / applies the suppliedSCMTrait
.- Parameters:
traits
- the additionalSCMTrait
instances.- Returns:
this
for method chaining.
-
withDecorator
@NonNull public final C withDecorator(@NonNull SCMSourceDecorator<?,?> decorator)
Adds the suppliedSCMSourceDecorator
.- Parameters:
decorator
- the additionalSCMSourceDecorator
.- Returns:
this
for method chaining.
-
withDecorators
@NonNull public final C withDecorators(@NonNull SCMSourceDecorator<?,?>... decorators)
Adds the suppliedSCMSourceDecorator
instances.- Parameters:
decorators
- the additionalSCMSourceDecorator
instances.- Returns:
this
for method chaining.
-
withDecorators
@NonNull public final C withDecorators(@NonNull Collection<? extends SCMSourceDecorator<?,?>> decorators)
Adds the suppliedSCMSourceDecorator
instances.- Parameters:
decorators
- the additionalSCMSourceDecorator
instances.- Returns:
this
for method chaining.
-
newRequest
@NonNull public abstract R newRequest(@NonNull SCMNavigator navigator, @NonNull SCMSourceObserver observer)
Creates a newSCMNavigatorRequest
.- Parameters:
navigator
- theSCMNavigator
.observer
- theSCMSourceObserver
.- Returns:
- the
SCMNavigatorContext
-
-