Class AbstractBuilder<T>

  • Type Parameters:
    T - the instance class type to build
    All Implemented Interfaces:
    Builder<T>
    Direct Known Subclasses:
    ExtensibleBuilder

    public abstract class AbstractBuilder<T>
    extends Object
    implements Builder<T>
    Base class for any Builder.

    Any AbstractBuilder keeps a reference to the instance under construction. This reference is created thanks to newBuildingInstance() and finally returned when calling build()

    Author:
    Aurelien Bourdon
    • Constructor Detail

      • AbstractBuilder

        protected AbstractBuilder()
    • Method Detail

      • newBuildingInstance

        protected abstract T newBuildingInstance()
        Create the new instance that will be build by this AbstractBuilder
        Returns:
        the new instance that will be build by this AbstractBuilder
      • getBuildingInstance

        protected T getBuildingInstance()
        Get the instance under construction
        Returns:
        the instance under construction
      • build

        public T build()
        Finalize the build of the instance under construction and get it
        Specified by:
        build in interface Builder<T>
        Returns:
        the created instance by this AbstractBuilder