B
- the type of SCMSourceBuilder
so that subclasses can chain correctly in their
withTrait(SCMSourceTrait)
etc methods.S
- the type of SCMSource
returned by build()
. In general this should be a type that
has SCMSourceTrait
support.public abstract class SCMSourceBuilder<B extends SCMSourceBuilder<B,S>,S extends SCMSource> extends Object
SCMSource
instance. Typically instantiated in
SCMNavigator.visitSources(SCMSourceObserver)
and then decorated by
SCMNavigatorTrait.applyToBuilder(SCMSourceBuilder)
before calling build()
to generate the return
value. Conventions:
final
or abstract
unless there is a documented reason for
allowing overridesB
and be called "withXxx"return Collections.unmodifiableList(theList);
rather than the concurrency safe
return 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 and Description |
---|
SCMSourceBuilder(Class<S> clazz,
String projectName)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
abstract S |
build()
Instantiates the
SCMSource . |
String |
projectName()
Returns the project name.
|
Class<S> |
sourceClass()
Returns the base class of
SCMSource that will be produced by the SCMSourceBuilder . |
List<SCMSourceTrait> |
traits()
Returns the
SCMSourceTrait instances to provide to the SCMSource (assuming the SCMSource
is SCMSourceTrait aware. |
B |
withRequest(SCMNavigatorRequest request)
Apply the
SCMNavigatorRequest to this SCMSourceBuilder . |
B |
withTrait(SCMNavigatorTrait trait)
Apply the
SCMNavigatorTrait to this SCMSourceBuilder . |
B |
withTrait(SCMSourceTrait trait)
|
B |
withTraits(Collection<? extends SCMTrait<?>> traits)
Apply the
SCMTrait instances to this SCMSourceBuilder . |
B |
withTraits(SCMTrait<? extends SCMTrait<?>>... traits)
Apply the
SCMTrait instances to this SCMSourceBuilder . |
public SCMSourceBuilder(@NonNull Class<S> clazz, @NonNull String projectName)
clazz
- the base class of SCMSource
that will be produced by the SCMSourceBuilder
.projectName
- the project name.@NonNull public final Class<S> sourceClass()
SCMSource
that will be produced by the SCMSourceBuilder
.SCMSource
that will be produced by the SCMSourceBuilder
.@NonNull public final String projectName()
@NonNull public final List<SCMSourceTrait> traits()
SCMSourceTrait
instances to provide to the SCMSource
(assuming the SCMSource
is SCMSourceTrait
aware.SCMSourceTrait
instances to provide to the SCMSource
(assuming the
SCMSource
is SCMSourceTrait
aware.@NonNull public final B withTrait(@NonNull SCMNavigatorTrait trait)
SCMNavigatorTrait
to this SCMSourceBuilder
.trait
- the SCMNavigatorTrait
.this
for method chaining.@NonNull public final B withTrait(@NonNull SCMSourceTrait trait)
trait
- the SCMSourceTrait
.this
for method chaining.@NonNull public final B withTraits(@NonNull SCMTrait<? extends SCMTrait<?>>... traits)
SCMTrait
instances to this SCMSourceBuilder
.traits
- the SCMTrait
instances.this
for method chaining.@NonNull public B withTraits(@NonNull Collection<? extends SCMTrait<?>> traits)
SCMTrait
instances to this SCMSourceBuilder
.traits
- the SCMTrait
instances.this
for method chaining.public B withRequest(@NonNull SCMNavigatorRequest request)
SCMNavigatorRequest
to this SCMSourceBuilder
.request
- the SCMNavigatorRequest
instance.this
for method chaining.Copyright © 2016–2022. All rights reserved.