Package jenkins.scm.api.trait
Class SCMBuilder<B extends SCMBuilder<B,S>,S extends SCM>
java.lang.Object
jenkins.scm.api.trait.SCMBuilder<B,S>
- Type Parameters:
B
- the type ofSCMBuilder
so that subclasses can chain correctly in theirwithHead(SCMHead)
etc methods.S
- the type ofSCM
returned bybuild()
Builder for a
SCM
instance. Typically instantiated in SCMSource.build(SCMHead, SCMRevision)
or
SCMSource.build(SCMHead)
and then decorated by SCMSourceTrait.applyToBuilder(SCMBuilder)
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
SCMBuilder
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));
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract S
build()
Instantiates theSCM
.final SCMHead
head()
final SCMRevision
revision()
scmClass()
Returns the base class ofSCM
that will be produced by theSCMBuilder
.final B
final B
withRevision
(SCMRevision revision) Replace therevision()
with a newSCMRevision
final B
withTrait
(SCMSourceTrait trait) Apply theSCMSourceTrait
to thisSCMBuilder
.final B
withTraits
(Collection<SCMSourceTrait> traits) Apply theSCMSourceTrait
instances to thisSCMBuilder
.final B
withTraits
(SCMSourceTrait... traits) Apply theSCMSourceTrait
instances to thisSCMBuilder
.
-
Constructor Details
-
SCMBuilder
Constructor.- Parameters:
clazz
- The base class ofSCM
that will be produced by theSCMBuilder
.head
- TheSCMHead
to produce theSCM
for.revision
- TheSCMRevision
to produce theSCM
for ornull
to produce theSCM
for the head revision.
-
-
Method Details
-
head
-
revision
- Returns:
- the
SCMRevision
to produce theSCM
for ornull
to produce theSCM
for the head revision.
-
scmClass
Returns the base class ofSCM
that will be produced by theSCMBuilder
.- Returns:
- the base class of
SCM
that will be produced by theSCMBuilder
.
-
withHead
-
withRevision
Replace therevision()
with a newSCMRevision
- Parameters:
revision
- theSCMRevision
to produce theSCM
for ornull
to produce theSCM
for the head revision.- Returns:
this
for method chaining.
-
withTrait
Apply theSCMSourceTrait
to thisSCMBuilder
.- Parameters:
trait
- theSCMSourceTrait
.- Returns:
this
for method chaining.
-
withTraits
Apply theSCMSourceTrait
instances to thisSCMBuilder
.- Parameters:
traits
- theSCMSourceTrait
instances.- Returns:
this
for method chaining.
-
withTraits
Apply theSCMSourceTrait
instances to thisSCMBuilder
.- Parameters:
traits
- theSCMSourceTrait
instances.- Returns:
this
for method chaining.
-
build
Instantiates theSCM
.- Returns:
- the
SCMBuilder
instance
-