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
public abstract class SCMHeadObserver extends Object
Something that observesSCMHead
and correspondingSCMRevision
details.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SCMHeadObserver.AllFinished
An observer that wraps multiple observers and keeps observing as long as one of the wrapped observers wants to.static class
SCMHeadObserver.Any
An observer that picks the first revision it can find.static class
SCMHeadObserver.Collector
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
SCMHeadObserver.Named
An observer that collects theSCMRevision
of a namedSCMHead
and then stops observing.static class
SCMHeadObserver.None
An observer that is already finished.static class
SCMHeadObserver.OneFinished
An observer that wraps multiple observers and keeps observing until one of the wrapped observers stops observing.static class
SCMHeadObserver.Selector
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
Constructors Constructor Description SCMHeadObserver()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static 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>filter(O delegate, SCMHead... heads)
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.Set<SCMHead>
getIncludes()
boolean
isObserving()
Returns information about whether the observer wants more results.static SCMHeadObserver.Named
named(String headName)
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
select(SCMHead head)
Creates an observer that selects the revision of a specific head.
-
-
-
Method Detail
-
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
@CheckForNull public Set<SCMHead> 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
@NonNull public static 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.- Parameters:
observers
- the observers to wrap.- Returns:
- a wrapped observer.
-
first
@NonNull public static SCMHeadObserver.OneFinished first(SCMHeadObserver... observers)
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
@NonNull public static SCMHeadObserver.Collector collect()
Creates an observer that collects all the heads and revisions.- Returns:
- an observer that collects all the heads and revisions.
-
select
@NonNull public static SCMHeadObserver.Selector select(@NonNull SCMHead head)
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
@NonNull public static SCMHeadObserver.Named named(@NonNull String headName)
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
@NonNull public static SCMHeadObserver.Any 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
@NonNull public static SCMHeadObserver.None 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
-
-