Interface Creator

All Known Implementing Classes:
SignatureCreator

interface Creator
The Instantiator object is used to represent an single constructor within an object. It contains the actual constructor as well as the list of parameters. Each instantiator will score its weight when given a Criteria object. This allows the deserialization process to find the most suitable one to use when instantiating an object.
  • Method Summary

    Modifier and Type
    Method
    Description
    This is used to instantiate the object using the default no argument constructor.
    This is used to instantiate the object using a constructor that takes deserialized objects as arguments.
    double
    getScore(Criteria criteria)
    This is used to score this Instantiator object so that it can be weighed amongst other constructors.
    This is the signature associated with the creator.
    This is the type associated with the Creator object.
  • Method Details

    • getInstance

      Object getInstance() throws Exception
      This is used to instantiate the object using the default no argument constructor. If for some reason the object can not be instantiated then this will throw an exception with the reason.
      Returns:
      this returns the object that has been instantiated
      Throws:
      Exception
    • getInstance

      Object getInstance(Criteria criteria) throws Exception
      This is used to instantiate the object using a constructor that takes deserialized objects as arguments. The object that have been deserialized can be taken from the Criteria object which contains the deserialized values.
      Parameters:
      criteria - this contains the criteria to be used
      Returns:
      this returns the object that has been instantiated
      Throws:
      Exception
    • getScore

      double getScore(Criteria criteria) throws Exception
      This is used to score this Instantiator object so that it can be weighed amongst other constructors. The instantiator that scores the highest is the one that is used for insIntantiation.

      If any read only element or attribute is not a parameter in the constructor then the constructor is discounted. This is because there is no way to set the read only entity without a constructor injection in to the instantiated object.

      Parameters:
      criteria - this contains the criteria to be used
      Returns:
      this returns the score based on the criteria provided
      Throws:
      Exception
    • getSignature

      Signature getSignature() throws Exception
      This is the signature associated with the creator. The signature contains all the parameters associated with the creator as well as the constructor that this represents. Exposing the signature allows the creator to be validated.
      Returns:
      this is the signature associated with the creator
      Throws:
      Exception
    • getType

      Class getType() throws Exception
      This is the type associated with the Creator object. All instances returned from this creator will be of this type.
      Returns:
      this returns the type associated with this creator
      Throws:
      Exception