Package jenkins.scm.api.trait
Class SCMSourceRequest
java.lang.Object
jenkins.scm.api.trait.SCMSourceRequest
- All Implemented Interfaces:
Closeable
,AutoCloseable
Represents the context of an individual request for a call to
SCMSource.retrieve(SCMSourceCriteria, SCMHeadObserver, SCMHeadEvent, TaskListener)
or an equivalent method.- Since:
- 2.2.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A lambda that produces an intermediate summary used to drive creation of theSCMSourceCriteria.Probe
andSCMRevision
instances.static interface
SCMSourceRequest.LazyRevisionLambda<H extends SCMHead,
R extends SCMRevision, I> A lambda that will create theSCMRevision
instance for a specificSCMHead
using the intermediate value produced by aSCMSourceRequest.IntermediateLambda
.static interface
SCMSourceRequest.ProbeLambda<H extends SCMHead,
I> A lambda that will create aSCMSourceCriteria.Probe
(ideally aSCMProbe
but for legacy code migration we useSCMSourceCriteria.Probe
) for a specifiedSCMHead
and either aSCMRevision
or some other type created by aSCMSourceRequest.IntermediateLambda
.static interface
SCMSourceRequest.RevisionLambda<H extends SCMHead,
R extends SCMRevision> A lambda that will create theSCMRevision
instance for a specificSCMHead
.static interface
SCMSourceRequest.Witness<H extends SCMHead,
R extends SCMRevision> Callback lambda to track the results ofprocess(SCMHead, IntermediateLambda, ProbeLambda, LazyRevisionLambda, Witness[])
-
Constructor Summary
ModifierConstructorDescriptionprotected
SCMSourceRequest
(SCMSource source, SCMSourceContext<?, ?> context, TaskListener listener) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
final List<SCMSourceCriteria>
Returns theSCMSourceCriteria
being used for this request.boolean
Checks if this request has been completed, that is if itsSCMHeadObserver
has stoppedSCMHeadObserver.isObserving()
.final boolean
isExcluded
(SCMHead head) Tests if theSCMHead
is excluded from the request.final boolean
Tests if theSCMHead
is trusted.listener()
Returns theTaskListener
to use for this request.void
Adds managing aCloseable
into the scope of theSCMSourceRequest
final <H extends SCMHead,
I, R extends SCMRevision>
booleanprocess
(H head, SCMSourceRequest.IntermediateLambda<I> intermediateFactory, SCMSourceRequest.ProbeLambda<H, I> probeFactory, SCMSourceRequest.LazyRevisionLambda<H, R, I> revisionFactory, SCMSourceRequest.Witness... witnesses) Processes a head in the context of the current request where an intermediary operation is required before theSCMRevision
can be instantiated.final <H extends SCMHead,
R extends SCMRevision>
booleanprocess
(H head, SCMSourceRequest.RevisionLambda<H, R> revisionFactory, SCMSourceRequest.ProbeLambda<H, R> probeFactory, SCMSourceRequest.Witness... witnesses) Processes a head in the context of the current request.final <H extends SCMHead,
R extends SCMRevision>
booleanprocess
(H head, R revision, SCMSourceRequest.ProbeLambda<H, R> probeFactory, SCMSourceRequest.Witness... witnesses) Processes a head in the context of the current request.
-
Constructor Details
-
SCMSourceRequest
protected SCMSourceRequest(@NonNull SCMSource source, @NonNull SCMSourceContext<?, ?> context, @CheckForNull TaskListener listener) Constructor.- Parameters:
source
- the source.context
- the context.listener
- the (optional)TaskListener
.
-
-
Method Details
-
isExcluded
Tests if theSCMHead
is excluded from the request.- Parameters:
head
- theSCMHead
.- Returns:
true
if theSCMHead
is excluded.- Throws:
IOException
- if there is an I/O error.InterruptedException
- if the operation was interrupted.
-
isTrusted
Tests if theSCMHead
is trusted.- Parameters:
head
- theSCMHead
.- Returns:
true
if theSCMHead
is trusted.- Throws:
IOException
- if there is an I/O error.InterruptedException
- if the operation was interrupted.
-
getCriteria
Returns theSCMSourceCriteria
being used for this request.- Returns:
- the
SCMSourceCriteria
being used for this request.
-
process
public final <H extends SCMHead,R extends SCMRevision> boolean process(@NonNull H head, @NonNull R revision, @NonNull SCMSourceRequest.ProbeLambda<H, R> probeFactory, @NonNull SCMSourceRequest.Witness... witnesses) throws IOException, InterruptedExceptionProcesses a head in the context of the current request.- Type Parameters:
H
- the type ofSCMHead
.R
- the type ofSCMRevision
.- Parameters:
head
- theSCMHead
to process.revision
- theSCMRevision
(assuming revision creation is very cheap).probeFactory
- factory method that creates theSCMProbe
.witnesses
- anySCMSourceRequest.Witness
instances to be informed of the observation result.- Returns:
true
if theSCMHeadObserver
for this request has completed observing,false
to continue processing.- Throws:
IOException
- if there was an I/O error.InterruptedException
- if the processing was interrupted.
-
process
public final <H extends SCMHead,R extends SCMRevision> boolean process(@NonNull H head, @NonNull SCMSourceRequest.RevisionLambda<H, R> revisionFactory, @NonNull SCMSourceRequest.ProbeLambda<H, throws IOException, InterruptedExceptionR> probeFactory, @NonNull SCMSourceRequest.Witness... witnesses) Processes a head in the context of the current request.- Type Parameters:
H
- the type ofSCMHead
.R
- the type ofSCMRevision
.- Parameters:
head
- theSCMHead
to process.revisionFactory
- factory method that creates theSCMRevision
(assuming creation is cheap).probeFactory
- factory method that creates theSCMProbe
.witnesses
- anySCMSourceRequest.Witness
instances to be informed of the observation result.- Returns:
true
if theSCMHeadObserver
for this request has completed observing,false
to continue processing.- Throws:
IOException
- if there was an I/O error.InterruptedException
- if the processing was interrupted.
-
process
public final <H extends SCMHead,I, boolean processR extends SCMRevision> (@NonNull H head, @CheckForNull SCMSourceRequest.IntermediateLambda<I> intermediateFactory, @NonNull SCMSourceRequest.ProbeLambda<H, I> probeFactory, @NonNull SCMSourceRequest.LazyRevisionLambda<H, throws IOException, InterruptedExceptionR, I> revisionFactory, @NonNull SCMSourceRequest.Witness... witnesses) Processes a head in the context of the current request where an intermediary operation is required before theSCMRevision
can be instantiated.- Type Parameters:
H
- the type ofSCMHead
.I
- the type of the intermediary operation result.R
- the type ofSCMRevision
.- Parameters:
head
- theSCMHead
to process.intermediateFactory
- factory method that provides the seed information for both theSCMSourceRequest.ProbeLambda
and theSCMSourceRequest.LazyRevisionLambda
.probeFactory
- factory method that creates theSCMProbe
.revisionFactory
- factory method that creates theSCMRevision
.witnesses
- anySCMSourceRequest.Witness
instances to be informed of the observation result.- Returns:
true
if theSCMHeadObserver
for this request has completed observing,false
to continue processing.- Throws:
IOException
- if there was an I/O error.InterruptedException
- if the processing was interrupted.
-
isComplete
public boolean isComplete()Checks if this request has been completed, that is if itsSCMHeadObserver
has stoppedSCMHeadObserver.isObserving()
.- Returns:
true
if and only if the request is completed.
-
listener
Returns theTaskListener
to use for this request.- Returns:
- the
TaskListener
to use for this request.
-
manage
Adds managing aCloseable
into the scope of theSCMSourceRequest
- Parameters:
closeable
- theCloseable
to manage.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-