T - The target type: an instance of that type is associated with the charger instance
to hold the data to be collected during the build process.
That type is expected to be mutable, at least in the scope of the concrete charger implementation.C - The charger type: the intended effective type of the concrete charger implementation.public class Charger<T,C extends Charger<T,C>> extends ProtoBuilder<T,C> implements Setup<T,C>
<C> and as such provides a model that
separates basic builder concepts from the actual target data model <T>.
This implementation can be used as a base if an instance of the target type should be associated with the charger instance from the start and also be used as the result of the charging process.
An instance of this charger type is limited to single use.
Once the terminating charged() method has been used, subsequent calls to ProtoBuilder.setup(Consumer) throw an
IllegalStateException.
ProtoBuilder.Lifecycle| Modifier | Constructor and Description |
|---|---|
protected |
Charger(T target,
Class<C> chargerClass)
Initializes a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
T |
charged()
Returns the associated target instance.
|
build, setupTHISprotected Charger(T target, Class<C> chargerClass)
target - The target instance to be associated with the charger.
The implementation assumes that it is exclusively available to the charger
for the course of the build process.chargerClass - The Class representation of the intended effective charger type.IllegalArgumentException - if the given charger class does not represent this instance.public final T charged()
Subsequent calls of ProtoBuilder.setup(Consumer) will lead to an IllegalStateException!
Copyright © 2024 Andreas Kluge-Kaindl, Bremen (de). All rights reserved.