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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.Object getInstance()
      This is used to instantiate the object using the default no argument constructor.
      java.lang.Object getInstance​(Criteria criteria)
      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.
      Signature getSignature()
      This is the signature associated with the creator.
      java.lang.Class getType()
      This is the type associated with the Creator object.
    • Method Detail

      • getInstance

        java.lang.Object getInstance()
                              throws java.lang.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:
        java.lang.Exception
      • getInstance

        java.lang.Object getInstance​(Criteria criteria)
                              throws java.lang.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:
        java.lang.Exception
      • getScore

        double getScore​(Criteria criteria)
                 throws java.lang.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:
        java.lang.Exception
      • getSignature

        Signature getSignature()
                        throws java.lang.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:
        java.lang.Exception
      • getType

        java.lang.Class getType()
                         throws java.lang.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:
        java.lang.Exception