HierarchyOfFactories

Use a hierarchy of factories, each of which understands the criteria for making a packet of its type, and knows about the immediate subtypes

Definition

Use a hierarchy of factories, each of which understands the criteria for making a packet of its type, and knows about the immediate subtypes, to create the objects for a ParserBuilder.  This allows extensibility of the factories and created objects to parallel the extensibility of the token set identifying the objects to be created. 

Source

Hierarchy Of Factories

Discussion

If registering new factories with the top-level factory, then a hierarchy is not needed, the subtypes need not be known until run time, so extending the set does not affect the parent factory code.  This may be done with some variants of Observer and / or Chain of Responsibility DesignPatterns.  If used in conjunction with ParserBuilder, then the factories will need to conform to the Builder DesignPattern.