apoc.generate.node.DefaultNodeCreator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apoc Show documentation
Show all versions of apoc Show documentation
A collection of useful Neo4j Procedures
package apoc.generate.node;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.Node;
/**
* A {@link NodeCreator} that assigns every {@link Node} a {@link Label} passed to it in the constructor and a UUID as
* a property.
*/
public class DefaultNodeCreator implements NodeCreator {
private static final String UUID = "uuid";
private final Label label;
public DefaultNodeCreator(String label) {
this.label = Label.label(label);
}
/**
* {@inheritDoc}
*/
@Override
public Node createNode(GraphDatabaseService database) {
Node node = database.createNode(label);
node.setProperty(UUID, java.util.UUID.randomUUID().toString());
return node;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy