Class InstanceFactory


  • class InstanceFactory
    extends java.lang.Object
    The Instantiator is used to instantiate types that will leverage a constructor cache to quickly create the objects. This is used by the various object factories to return type instances that can be used by converters to create the objects that will later be deserialized.
    See Also:
    Instance
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private class  InstanceFactory.ClassInstance
      The ClassInstance object is used to create an object by using a Class to determine the type.
      private class  InstanceFactory.ValueInstance
      The ValueInstance object is used to create an object by using a Value instance to determine the type.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Cache<java.lang.reflect.Constructor> cache
      This is used to cache the constructors for the given types.
    • Constructor Summary

      Constructors 
      Constructor Description
      InstanceFactory()
      Constructor for the Instantiator object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Instance getInstance​(java.lang.Class type)
      This will create an Instance that can be used to instantiate objects of the specified class.
      Instance getInstance​(Value value)
      This will create an Instance that can be used to instantiate objects of the specified class.
      protected java.lang.Object getObject​(java.lang.Class type)
      This method will instantiate an object of the provided type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • cache

        private final Cache<java.lang.reflect.Constructor> cache
        This is used to cache the constructors for the given types.
    • Constructor Detail

      • InstanceFactory

        public InstanceFactory()
        Constructor for the Instantiator object. This will create a constructor cache that can be used to cache all of the constructors instantiated for the required types.
    • Method Detail

      • getInstance

        public Instance getInstance​(Value value)
        This will create an Instance that can be used to instantiate objects of the specified class. This leverages an internal constructor cache to ensure creation is quicker.
        Parameters:
        value - this contains information on the object instance
        Returns:
        this will return an object for instantiating objects
      • getInstance

        public Instance getInstance​(java.lang.Class type)
        This will create an Instance that can be used to instantiate objects of the specified class. This leverages an internal constructor cache to ensure creation is quicker.
        Parameters:
        type - this is the type that is to be instantiated
        Returns:
        this will return an object for instantiating objects
      • getObject

        protected java.lang.Object getObject​(java.lang.Class type)
                                      throws java.lang.Exception
        This method will instantiate an object of the provided type. If the object or constructor does not have public access then this will ensure the constructor is accessible and can be used.
        Parameters:
        type - this is used to ensure the object is accessible
        Returns:
        this returns an instance of the specific class type
        Throws:
        java.lang.Exception