Package jenkins.scm.api
Class SCMHeadObserver
java.lang.Object
jenkins.scm.api.SCMHeadObserver
- Direct Known Subclasses:
SCMHeadObserver.AllFinished
,SCMHeadObserver.Any
,SCMHeadObserver.Collector
,SCMHeadObserver.Named
,SCMHeadObserver.None
,SCMHeadObserver.OneFinished
,SCMHeadObserver.Selector
,SCMHeadObserver.Wrapped
Something that observes
SCMHead
and corresponding SCMRevision
details.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An observer that wraps multiple observers and keeps observing as long as one of the wrapped observers wants to.static class
An observer that picks the first revision it can find.static class
An observer that collects the observedSCMHead
s andSCMRevision
s.static class
SCMHeadObserver.Filter<O extends SCMHeadObserver>
ASCMHeadObserver
that filters theSCMHead
instances that will be observed by the wrappedSCMHeadObserver
.static class
An observer that collects theSCMRevision
of a namedSCMHead
and then stops observing.static final class
An observer that is already finished.static class
An observer that wraps multiple observers and keeps observing until one of the wrapped observers stops observing.static class
An observer that collects theSCMRevision
of a specificSCMHead
and then stops observing.static class
SCMHeadObserver.Wrapped<O extends SCMHeadObserver>
Base class for anSCMHeadObserver
that wraps anotherSCMHeadObserver
while allowing access to the original observer viaSCMHeadObserver.Wrapped.unwrap()
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic SCMHeadObserver.AllFinished
allOf
(SCMHeadObserver... observers) Wraps multiple observers returning a combined observer that remains observing as long as at least one of the wrapped observers is still observing.static SCMHeadObserver.Any
any()
Creates an observer that selects the first revision it finds.static SCMHeadObserver.Collector
collect()
Creates an observer that collects all the heads and revisions.static <O extends SCMHeadObserver>
SCMHeadObserver.Filter<O>Creates an observer that filters a delegates observer to the specified headsstatic SCMHeadObserver.OneFinished
first
(SCMHeadObserver... observers) Wraps multiple observers returning a combined observer that remains observing until one of the wrapped observers stops observing.boolean
Returns information about whether the observer wants more results.static SCMHeadObserver.Named
Creates an observer that selects the revision of a specific head.static SCMHeadObserver.None
none()
Creates an observer that selects the first revision it finds.abstract void
observe
(SCMHead head, SCMRevision revision) Observes a head and current revision.static SCMHeadObserver.Selector
Creates an observer that selects the revision of a specific head.
-
Constructor Details
-
SCMHeadObserver
public SCMHeadObserver()
-
-
Method Details
-
observe
public abstract void observe(@NonNull SCMHead head, @NonNull SCMRevision revision) throws IOException, InterruptedException Observes a head and current revision.- Parameters:
head
- the head.revision
- the revision.- Throws:
IOException
- if processing of the observation could not be completed due to anIOException
.InterruptedException
- if processing of the observation was interrupted
-
isObserving
public boolean isObserving()Returns information about whether the observer wants more results.- Returns:
true
if the observer is still observing orfalse
to signal that it is ok to stop early.
-
getIncludes
Returns the subset ofSCMHead
instances that this observer is interested in ornull
if interested in allSCMHead
instances.Implementations should not assume that the
getIncludes()
will be honoured. This method is designed to provide a hint toSCMSource
implementations.- Returns:
- the subset of
SCMHead
instances that this observer is interested in ornull
. - Since:
- 2.0
-
allOf
Wraps multiple observers returning a combined observer that remains observing as long as at least one of the wrapped observers is still observing.- Parameters:
observers
- the observers to wrap.- Returns:
- a wrapped observer.
-
first
Wraps multiple observers returning a combined observer that remains observing until one of the wrapped observers stops observing.- Parameters:
observers
- the observers to wrap.- Returns:
- a wrapped observer.
-
collect
Creates an observer that collects all the heads and revisions.- Returns:
- an observer that collects all the heads and revisions.
-
select
Creates an observer that selects the revision of a specific head.- Parameters:
head
- the head to watch out for.- Returns:
- an observer that selects the revision of a specific head.
-
filter
@NonNull public static <O extends SCMHeadObserver> SCMHeadObserver.Filter<O> filter(O delegate, SCMHead... heads) Creates an observer that filters a delegates observer to the specified heads- Type Parameters:
O
- the type of observer that will be filtered.- Parameters:
delegate
- the delegateheads
- the head to watch out for.- Returns:
- an observer that wraps the supplied delegate.
-
named
Creates an observer that selects the revision of a specific head.- Parameters:
headName
- the head to watch out for.- Returns:
- an observer that selects the revision of a specific head.
- Since:
- 2.0
-
any
Creates an observer that selects the first revision it finds. Also useful for quick checks of non-empty.- Returns:
- an observer that selects the first revision of a any head.
- Since:
- 2.0
-
none
Creates an observer that selects the first revision it finds. Also useful for quick checks of non-empty.- Returns:
- an observer that selects the first revision of a any head.
- Since:
- 2.2.0
-