Package jenkins.scm.api
Class SCMSourceObserver
java.lang.Object
jenkins.scm.api.SCMSourceObserver
- Direct Known Subclasses:
SCMSourceObserver.Wrapped
Callback used by
SCMNavigator
.- Since:
- 0.3-beta-1
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
SCMSourceObserver.Filter<O extends SCMSourceObserver>
An observer that filters the observed sources to a subset of named instances.static class
Nested callback produced byobserve(java.lang.String)
.static class
SCMSourceObserver.Wrapped<O extends SCMSourceObserver>
Base class for an observer that wraps another observer. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
addAttribute
(String key, Object value) Adds extra metadata about the overall organization.static <O extends SCMSourceObserver>
SCMSourceObserver.Filter<O>Creates an observer that filters a delegates observer to the specified project namesabstract SCMSourceOwner
Indicates who is asking for sources.Returns the subset of "project" names that this observer is interested in ornull
if interested in all "project" names.abstract TaskListener
Provides a way of reporting progress.boolean
Returns information about whether the observer wants more results.abstract SCMSourceObserver.ProjectObserver
Declare that a new "project" such as a source repository has been found.
-
Constructor Details
-
SCMSourceObserver
public SCMSourceObserver()
-
-
Method Details
-
getContext
Indicates who is asking for sources.- Returns:
- a contextual item, typically a
OrganizationFolder
-
getListener
Provides a way of reporting progress.- Returns:
- a logger
-
getIncludes
Returns the subset of "project" names that this observer is interested in ornull
if interested in all "project" names.Implementations should not assume that the
getIncludes()
will be honoured. This method is designed to provide a hint toSCMNavigator
implementations.- Returns:
- the subset of "project" names that this observer is interested in or
null
. - Since:
- 2.0
- See Also:
-
observe
@NonNull public abstract SCMSourceObserver.ProjectObserver observe(@NonNull String projectName) throws IllegalArgumentException, IOException, InterruptedException Declare that a new "project" such as a source repository has been found.- Parameters:
projectName
- a name of the project, such as a repository name within an organization; may be used as anItem.getName()
- Returns:
- a secondary callback to customize the project, on which you must call
SCMSourceObserver.ProjectObserver.complete()
- Throws:
IllegalArgumentException
- if thisprojectName
has already been encounteredIOException
- if observing thisprojectName
could not be completed due to anIOException
.InterruptedException
- if observing thisprojectName
was interrupted.
-
addAttribute
public abstract void addAttribute(@NonNull String key, @Nullable Object value) throws IllegalArgumentException, ClassCastException Adds extra metadata about the overall organization. Currently no metadata keys are defined; placeholder for description, icon, URL, etc.- Parameters:
key
- a predefined attribute namevalue
- some value, of a type defined by the attribute, perhaps null if allowed by the attribute documentation- Throws:
IllegalArgumentException
- if the attribute name is unrecognized, or this attribute was already addedClassCastException
- if the attribute value is inappropriate for its type
-
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.- Since:
- 2.0
-
filter
@NonNull public static <O extends SCMSourceObserver> SCMSourceObserver.Filter<O> filter(O delegate, String... projectNames) Creates an observer that filters a delegates observer to the specified project names- Type Parameters:
O
- the type of observer that will be filtered.- Parameters:
delegate
- the delegateprojectNames
- the project names to watch out for.- Returns:
- an observer that wraps the supplied delegate.
- Since:
- 2.0
-