Package jenkins.scm.api.trait
Class SCMSourceBuilder<B extends SCMSourceBuilder<B,S>,S extends SCMSource>
java.lang.Object
jenkins.scm.api.trait.SCMSourceBuilder<B,S>
- Type Parameters:
B
- the type ofSCMSourceBuilder
so that subclasses can chain correctly in theirwithTrait(SCMSourceTrait)
etc methods.S
- the type ofSCMSource
returned bybuild()
. In general this should be a type that hasSCMSourceTrait
support.
public abstract class SCMSourceBuilder<B extends SCMSourceBuilder<B,S>,S extends SCMSource>
extends Object
Builder for a
SCMSource
instance. Typically instantiated in
SCMNavigator.visitSources(SCMSourceObserver)
and then decorated by
SCMNavigatorTrait.applyToBuilder(SCMSourceBuilder)
before calling build()
to generate the return
value. Conventions:
- The builder is not designed to be shared by multiple threads.
- All methods should be either
final
orabstract
unless there is a documented reason for allowing overrides - All "setter" methods will return
SCMSourceBuilder
and be called "withXxx" - All "getter" methods will be called "xxx()". Callers should not assume that the returned value is resistant
from concurrent changes. Implementations should ensure that the returned value is immutable by the caller.
In other words, it is intentional for implementations to reduce intermediate allocations by
return Collections.unmodifiableList(theList);
rather than the concurrency safereturn Collections.unmodifiableList(new ArrayList<>(theList));
SCMTrait
instances to the builder, the SCMNavigatorTrait
instances will modify the
builder itself while the SCMSourceTrait
instances will be retained to be added to the SCMSource
during build()
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract S
build()
Instantiates theSCMSource
.final String
Returns the project name.Returns the base class ofSCMSource
that will be produced by theSCMSourceBuilder
.final List<SCMSourceTrait>
traits()
Returns theSCMSourceTrait
instances to provide to theSCMSource
(assuming theSCMSource
isSCMSourceTrait
aware.withRequest
(SCMNavigatorRequest request) Apply theSCMNavigatorRequest
to thisSCMSourceBuilder
.final B
withTrait
(SCMNavigatorTrait trait) Apply theSCMNavigatorTrait
to thisSCMSourceBuilder
.final B
withTrait
(SCMSourceTrait trait) withTraits
(Collection<? extends SCMTrait<?>> traits) Apply theSCMTrait
instances to thisSCMSourceBuilder
.final B
withTraits
(SCMTrait<? extends SCMTrait<?>>... traits) Apply theSCMTrait
instances to thisSCMSourceBuilder
.
-
Constructor Details
-
SCMSourceBuilder
Constructor.- Parameters:
clazz
- the base class ofSCMSource
that will be produced by theSCMSourceBuilder
.projectName
- the project name.
-
-
Method Details
-
sourceClass
Returns the base class ofSCMSource
that will be produced by theSCMSourceBuilder
.- Returns:
- the base class of
SCMSource
that will be produced by theSCMSourceBuilder
.
-
projectName
Returns the project name.- Returns:
- the project name.
-
traits
Returns theSCMSourceTrait
instances to provide to theSCMSource
(assuming theSCMSource
isSCMSourceTrait
aware.- Returns:
- the
SCMSourceTrait
instances to provide to theSCMSource
(assuming theSCMSource
isSCMSourceTrait
aware.
-
withTrait
- Parameters:
trait
- theSCMSourceTrait
.- Returns:
this
for method chaining.
-
withTraits
Apply theSCMTrait
instances to thisSCMSourceBuilder
.- Parameters:
traits
- theSCMTrait
instances.- Returns:
this
for method chaining.
-
withTraits
Apply theSCMTrait
instances to thisSCMSourceBuilder
.- Parameters:
traits
- theSCMTrait
instances.- Returns:
this
for method chaining.
-
build
Instantiates theSCMSource
. The implementation is responsible to ensure that thetraits()
are provided to theSCMSource
.- Returns:
- the
SCMSourceBuilder
instance
-