Package jenkins.scm.api.trait
Class SCMSourceRequest
- java.lang.Object
-
- jenkins.scm.api.trait.SCMSourceRequest
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public abstract class SCMSourceRequest extends Object implements Closeable
Represents the context of an individual request for a call toSCMSource.retrieve(SCMSourceCriteria, SCMHeadObserver, SCMHeadEvent, TaskListener)
or an equivalent method.- Since:
- 2.2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SCMSourceRequest.IntermediateLambda<I>
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
Constructors Modifier Constructor Description protected
SCMSourceRequest(SCMSource source, SCMSourceContext<?,?> context, TaskListener listener)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
List<SCMSourceCriteria>
getCriteria()
Returns theSCMSourceCriteria
being used for this request.boolean
isComplete()
Checks if this request has been completed, that is if itsSCMHeadObserver
has stoppedSCMHeadObserver.isObserving()
.boolean
isExcluded(SCMHead head)
Tests if theSCMHead
is excluded from the request.boolean
isTrusted(SCMHead head)
Tests if theSCMHead
is trusted.TaskListener
listener()
Returns theTaskListener
to use for this request.void
manage(Closeable closeable)
Adds managing aCloseable
into the scope of theSCMSourceRequest
<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.<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.<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 Detail
-
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 Detail
-
isExcluded
public final boolean isExcluded(@NonNull SCMHead head) throws IOException, InterruptedException
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
public final boolean isTrusted(@NonNull SCMHead head) throws IOException, InterruptedException
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
@NonNull public final List<SCMSourceCriteria> 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, InterruptedException
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.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,R> probeFactory, @NonNull SCMSourceRequest.Witness... witnesses) throws IOException, InterruptedException
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,R extends SCMRevision> boolean process(@NonNull H head, @CheckForNull SCMSourceRequest.IntermediateLambda<I> intermediateFactory, @NonNull SCMSourceRequest.ProbeLambda<H,I> probeFactory, @NonNull SCMSourceRequest.LazyRevisionLambda<H,R,I> revisionFactory, @NonNull SCMSourceRequest.Witness... witnesses) throws IOException, InterruptedException
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
@NonNull public TaskListener listener()
Returns theTaskListener
to use for this request.- Returns:
- the
TaskListener
to use for this request.
-
manage
public void manage(@CheckForNull Closeable closeable)
Adds managing aCloseable
into the scope of theSCMSourceRequest
- Parameters:
closeable
- theCloseable
to manage.
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-