Class GraphAdapterBuilder.Factory

    • Constructor Summary

      Constructors 
      Constructor Description
      Factory​(java.util.Map<java.lang.reflect.Type,​InstanceCreator<?>> instanceCreators)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> TypeAdapter<T> create​(Gson gson, TypeToken<T> type)
      Returns a type adapter for type, or null if this factory doesn't support type.
      java.lang.Object createInstance​(java.lang.reflect.Type type)
      Hook for the graph adapter to get a reference to a deserialized value before that value is fully populated.
      • Methods inherited from class java.lang.Object

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

      • instanceCreators

        private final java.util.Map<java.lang.reflect.Type,​InstanceCreator<?>> instanceCreators
    • Constructor Detail

      • Factory

        Factory​(java.util.Map<java.lang.reflect.Type,​InstanceCreator<?>> instanceCreators)
    • Method Detail

      • createInstance

        public java.lang.Object createInstance​(java.lang.reflect.Type type)
        Hook for the graph adapter to get a reference to a deserialized value before that value is fully populated. This is useful to deserialize values that directly or indirectly reference themselves: we can hand out an instance before read() returns.

        Gson should only ever call this method when we're expecting it to; that is only when we've called back into Gson to deserialize a tree.

        Specified by:
        createInstance in interface InstanceCreator
        Parameters:
        type - the parameterized T represented as a Type.
        Returns:
        a default object instance of type T.