Package org.neo4j.ogm.metadata.reflect
Class EntityFactory
java.lang.Object
org.neo4j.ogm.metadata.reflect.EntityFactory
A metadata-driven factory class for creating node and relationship entities.
- Author:
- Adam George, Nicolas Mervaillie
-
Constructor Summary
ConstructorDescriptionEntityFactory
(MetaData metadata) Compatibility constructor for SDN 5.0.EntityFactory
(MetaData metadata, EntityInstantiator entityInstantiator) Constructs a newEntityFactory
driven by the specifiedMetaData
. -
Method Summary
Modifier and TypeMethodDescription<T> T
Constructs a new instance of the specified class using the same logic as the graph model factory methods.<T> T
newObject
(org.neo4j.ogm.model.Node nodeModel) Constructs a new object based on the class mapped to the labels on the givenNode
.
-
Constructor Details
-
EntityFactory
Compatibility constructor for SDN 5.0.- Parameters:
metadata
- The mappingMetaData
-
EntityFactory
Constructs a newEntityFactory
driven by the specifiedMetaData
.- Parameters:
metadata
- The mappingMetaData
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 givenNode
. 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
- TheNode
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
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
-