Class Charger<T,C extends Charger<T,C>>

Type Parameters:
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.
All Implemented Interfaces:
Setup<T,C>

public class Charger<T,C extends Charger<T,C>> extends ProtoBuilder<T,C>
Serves as a base class for builder-like charger implementations <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 Setup.setup(Consumer) throw an IllegalStateException.

  • Constructor Details

    • Charger

      protected Charger(T target, Class<C> chargerClass)
      Initializes a new instance.
      Parameters:
      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.
      Throws:
      IllegalArgumentException - if the given charger class does not represent this instance.
  • Method Details