B - the type of SCMBuilder so that subclasses can chain correctly in their withHead(SCMHead)
etc methods.S - the type of SCM returned by build()public abstract class SCMBuilder<B extends SCMBuilder<B,S>,S extends SCM> extends Object
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:
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));
| Constructor and Description |
|---|
SCMBuilder(Class<S> clazz,
SCMHead head,
SCMRevision revision)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
abstract S |
build()
Instantiates the
SCM. |
SCMHead |
head()
|
SCMRevision |
revision()
|
Class<S> |
scmClass()
Returns the base class of
SCM that will be produced by the SCMBuilder. |
B |
withHead(SCMHead head)
|
B |
withRevision(SCMRevision revision)
Replace the
revision() with a new SCMRevision |
B |
withTrait(SCMSourceTrait trait)
Apply the
SCMSourceTrait to this SCMBuilder. |
B |
withTraits(Collection<SCMSourceTrait> traits)
Apply the
SCMSourceTrait instances to this SCMBuilder. |
B |
withTraits(SCMSourceTrait... traits)
Apply the
SCMSourceTrait instances to this SCMBuilder. |
public SCMBuilder(Class<S> clazz, @NonNull SCMHead head, @CheckForNull SCMRevision revision)
clazz - The base class of SCM that will be produced by the SCMBuilder.head - The SCMHead to produce the SCM for.revision - The SCMRevision to produce the SCM for or null to produce the
SCM for the head revision.@CheckForNull public final SCMRevision revision()
SCMRevision to produce the SCM for or null to produce the SCM for
the head revision.@NonNull public final Class<S> scmClass()
SCM that will be produced by the SCMBuilder.SCM that will be produced by the SCMBuilder.@NonNull public final B withRevision(@CheckForNull SCMRevision revision)
revision() with a new SCMRevisionrevision - the SCMRevision to produce the SCM for or null to produce the
SCM for the head revision.this for method chaining.@NonNull public final B withTrait(@NonNull SCMSourceTrait trait)
SCMSourceTrait to this SCMBuilder.trait - the SCMSourceTrait.this for method chaining.@NonNull public final B withTraits(@NonNull SCMSourceTrait... traits)
SCMSourceTrait instances to this SCMBuilder.traits - the SCMSourceTrait instances.this for method chaining.@NonNull public final B withTraits(@NonNull Collection<SCMSourceTrait> traits)
SCMSourceTrait instances to this SCMBuilder.traits - the SCMSourceTrait instances.this for method chaining.Copyright © 2016–2019. All rights reserved.