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 ofSCMBuilderso that subclasses can chain correctly in theirwithHead(SCMHead)etc methods.S- the type ofSCMreturned 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
finalorabstractunless there is a documented reason for allowing overrides - All "setter" methods will return
SCMBuilderand 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Sbuild()Instantiates theSCM.final SCMHeadhead()final SCMRevisionrevision()scmClass()Returns the base class ofSCMthat will be produced by theSCMBuilder.final Bfinal BwithRevision(SCMRevision revision) Replace therevision()with a newSCMRevisionfinal BwithTrait(SCMSourceTrait trait) Apply theSCMSourceTraitto thisSCMBuilder.final BwithTraits(Collection<SCMSourceTrait> traits) Apply theSCMSourceTraitinstances to thisSCMBuilder.final BwithTraits(SCMSourceTrait... traits) Apply theSCMSourceTraitinstances to thisSCMBuilder.
-
Constructor Details
-
SCMBuilder
Constructor.- Parameters:
clazz- The base class ofSCMthat will be produced by theSCMBuilder.head- TheSCMHeadto produce theSCMfor.revision- TheSCMRevisionto produce theSCMfor ornullto produce theSCMfor the head revision.
-
-
Method Details
-
head
-
revision
- Returns:
- the
SCMRevisionto produce theSCMfor ornullto produce theSCMfor the head revision.
-
scmClass
Returns the base class ofSCMthat will be produced by theSCMBuilder.- Returns:
- the base class of
SCMthat will be produced by theSCMBuilder.
-
withHead
-
withRevision
Replace therevision()with a newSCMRevision- Parameters:
revision- theSCMRevisionto produce theSCMfor ornullto produce theSCMfor the head revision.- Returns:
thisfor method chaining.
-
withTrait
Apply theSCMSourceTraitto thisSCMBuilder.- Parameters:
trait- theSCMSourceTrait.- Returns:
thisfor method chaining.
-
withTraits
Apply theSCMSourceTraitinstances to thisSCMBuilder.- Parameters:
traits- theSCMSourceTraitinstances.- Returns:
thisfor method chaining.
-
withTraits
Apply theSCMSourceTraitinstances to thisSCMBuilder.- Parameters:
traits- theSCMSourceTraitinstances.- Returns:
thisfor method chaining.
-
build
Instantiates theSCM.- Returns:
- the
SCMBuilderinstance
-