Class EntityFactory

java.lang.Object
org.neo4j.ogm.metadata.reflect.EntityFactory

public class EntityFactory extends Object
A metadata-driven factory class for creating node and relationship entities.
Author:
Adam George, Nicolas Mervaillie
  • Constructor Details

    • EntityFactory

      public EntityFactory(MetaData metadata)
      Compatibility constructor for SDN 5.0.
      Parameters:
      metadata - The mapping MetaData
    • EntityFactory

      public EntityFactory(MetaData metadata, EntityInstantiator entityInstantiator)
      Constructs a new EntityFactory driven by the specified MetaData.
      Parameters:
      metadata - The mapping MetaData
      entityInstantiator - The instantiation mechanism to be used.
  • Method Details

    • newObject

      public <T> T newObject(org.neo4j.ogm.model.Node nodeModel)
      Constructs a new object based on the class mapped to the labels on the given Node. In the case of multiple labels, only the one that identifies a class in the domain will be used, and if there are any ambiguities in which label to use then an exception will be thrown.
      Type Parameters:
      T - The class of object to return
      Parameters:
      nodeModel - The Node from which to determine the type
      Returns:
      A new instance of the class that corresponds to the node label, never null
      Throws:
      MappingException - if it's not possible to resolve or instantiate a class from the given argument
    • newObject

      public <T> T newObject(Class<T> clarse, Map<String,Object> map)
      Constructs a new instance of the specified class using the same logic as the graph model factory methods.
      Type Parameters:
      T - The class of object to return
      Parameters:
      clarse - The class to instantiate
      Returns:
      A new instance of the specified Class
      Throws:
      MappingException - if it's not possible to instantiate the given class for any reason