Abstract Factory Pattern
Abstract Factory patterns work around a super-factory which creates other factories. This factory is also called as factory of factories.
In Abstract Factory pattern an interface is responsible for creating a factory of related objects without explicitly specifying their classes. Each generated factory can give the objects as per the Factory pattern.
Implementation
building on Factory Pattern classes
We are going to create a Color interface and a concrete classes(RED/GREEN/BLUE) implementing it. We create an abstract factory class AbstractFactory as next step. we define Factory class ColorFactory, which extends AbstractFactory. A factory creator/generator class FactoryProducer is created to handle two factories.
AbstractFactoryPatternDemo, our demo class uses FactoryProducer to get an AbstractFactory object. It will pass information (CIRCLE / RECTANGLE / SQUARE for Shape) to AbstractFactory to get the type of object it needs.