Class BuilderBase<B extends BuilderBase<B>>

java.lang.Object
de.team33.patterns.building.elara.BuilderBase<B>
Type Parameters:
B - The builder type: the intended effective type of the concrete builder implementation.
Direct Known Subclasses:
LateBuilder, ProtoBuilder

public class BuilderBase<B extends BuilderBase<B>> extends Object
Base class of a generic class hierarchy that has a type parameter intended to represent the effective type of concrete implementation.

The main purpose is the realization of a generic builder pattern, whereby there should be methods that should result in this - i.e. the builder instance itself - in order to chain further method calls.

For this purpose, it should be ensured in the constructor that this actually corresponds to the designated type.

TODO: should be independent : "class SelfReferring"

  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    BuilderBase(Class<B> builderClass)
    Initializes a new instance and checks the intended builder type for consistency.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final B
    Returns this as an instance of the effective builder type <B>.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BuilderBase

      protected BuilderBase(Class<B> builderClass)
      Initializes a new instance and checks the intended builder type for consistency.
      Parameters:
      builderClass - The Class representation of the intended effective builder type.
      Throws:
      IllegalArgumentException - if the given builder class does not represent this instance.
  • Method Details

    • THIS

      protected final B THIS()
      Returns this as an instance of the effective builder type <B>.