Package Behavioral.TemplateMethod
Class AbstractClass
java.lang.Object
Behavioral.TemplateMethod.AbstractClass
- Direct Known Subclasses:
ConcreteClass1,ConcreteClass2
Abstract class defining the template method and the structure of the algorithm.
The template method defines a skeleton of the algorithm, deferring some steps to subclasses.
Subclasses must implement the required operations and can optionally override hooks.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidhook()Hook method that can be optionally overridden by subclasses.protected abstract voidAbstract method that subclasses must implement.protected abstract voidAbstract method that subclasses must implement.final voidTemplate method defining the algorithm structure.
-
Constructor Details
-
AbstractClass
public AbstractClass()Default constructor for AbstractClass.
-
-
Method Details
-
templateMethod
public final void templateMethod()Template method defining the algorithm structure. This method contains base operations and calls to abstract methods that must be implemented by subclasses. -
requiredOperation1
protected abstract void requiredOperation1()Abstract method that subclasses must implement. -
requiredOperation2
protected abstract void requiredOperation2()Abstract method that subclasses must implement. -
hook
protected void hook()Hook method that can be optionally overridden by subclasses. By default, it provides a no-op implementation.
-