Class ObjectFactory


class ObjectFactory extends PrimitiveFactory
The ObjectFactory is the most basic factory. This will basically check to see if there is an override type within the XML node provided, if there is then that is instantiated, otherwise the field type is instantiated. Any type created must have a default no argument constructor. If the override type is an abstract class or an interface then this factory throws an exception.
  • Constructor Details

    • ObjectFactory

      public ObjectFactory(Context context, Type type, Class override)
      Constructor for the ObjectFactory class. This is given the field class that this should create object instances of. If the field type is abstract then the XML node must have sufficient information for the Strategy object to resolve the implementation class to be instantiated.
      Parameters:
      context - the contextual object used by the persister
      type - this is the object type to use for this factory
  • Method Details

    • getInstance

      public Instance getInstance(InputNode node) throws Exception
      This method will instantiate an object of the field type, or if the Strategy object can resolve a class from the XML element then this is used instead. If the resulting type is abstract or an interface then this method throws an exception.
      Overrides:
      getInstance in class PrimitiveFactory
      Parameters:
      node - this is the node to check for the override
      Returns:
      this returns an instance of the resulting type
      Throws:
      Exception