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 ofSCMSourceBuilderso that subclasses can chain correctly in theirwithTrait(SCMSourceTrait)etc methods.S- the type ofSCMSourcereturned bybuild(). In general this should be a type that hasSCMSourceTraitsupport.
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
finalorabstractunless there is a documented reason for allowing overrides - All "setter" methods will return
SCMSourceBuilderand 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Sbuild()Instantiates theSCMSource.final StringReturns the project name.Returns the base class ofSCMSourcethat will be produced by theSCMSourceBuilder.final List<SCMSourceTrait>traits()Returns theSCMSourceTraitinstances to provide to theSCMSource(assuming theSCMSourceisSCMSourceTraitaware.withRequest(SCMNavigatorRequest request) Apply theSCMNavigatorRequestto thisSCMSourceBuilder.final BwithTrait(SCMNavigatorTrait trait) Apply theSCMNavigatorTraitto thisSCMSourceBuilder.final BwithTrait(SCMSourceTrait trait) withTraits(Collection<? extends SCMTrait<?>> traits) Apply theSCMTraitinstances to thisSCMSourceBuilder.final BwithTraits(SCMTrait<? extends SCMTrait<?>>... traits) Apply theSCMTraitinstances to thisSCMSourceBuilder.
-
Constructor Details
-
SCMSourceBuilder
Constructor.- Parameters:
clazz- the base class ofSCMSourcethat will be produced by theSCMSourceBuilder.projectName- the project name.
-
-
Method Details
-
sourceClass
Returns the base class ofSCMSourcethat will be produced by theSCMSourceBuilder.- Returns:
- the base class of
SCMSourcethat will be produced by theSCMSourceBuilder.
-
projectName
Returns the project name.- Returns:
- the project name.
-
traits
Returns theSCMSourceTraitinstances to provide to theSCMSource(assuming theSCMSourceisSCMSourceTraitaware.- Returns:
- the
SCMSourceTraitinstances to provide to theSCMSource(assuming theSCMSourceisSCMSourceTraitaware.
-
withTrait
- Parameters:
trait- theSCMSourceTrait.- Returns:
thisfor method chaining.
-
withTraits
Apply theSCMTraitinstances to thisSCMSourceBuilder.- Parameters:
traits- theSCMTraitinstances.- Returns:
thisfor method chaining.
-
withTraits
Apply theSCMTraitinstances to thisSCMSourceBuilder.- Parameters:
traits- theSCMTraitinstances.- Returns:
thisfor method chaining.
-
build
Instantiates theSCMSource. The implementation is responsible to ensure that thetraits()are provided to theSCMSource.- Returns:
- the
SCMSourceBuilderinstance
-