All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lordofthejars.nosqlunit.neo4j.EmbeddedNeo4jInstances Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.lordofthejars.nosqlunit.neo4j;

import static ch.lambdaj.collection.LambdaCollections.with;
import static org.hamcrest.CoreMatchers.anything;

import java.util.HashMap;
import java.util.Map;

import org.neo4j.graphdb.GraphDatabaseService;

public final class EmbeddedNeo4jInstances {

	private static EmbeddedNeo4jInstances embeddedInstances;
	
	private Map instances = new HashMap();
	
	private EmbeddedNeo4jInstances() {
		super();
	}

	public static synchronized EmbeddedNeo4jInstances getInstance() {
		if (embeddedInstances == null) {
			embeddedInstances = new EmbeddedNeo4jInstances();
		}
		return embeddedInstances;
	}
	
	public void addGraphDatabaseService(GraphDatabaseService graphDatabaseService, String targetPath) {
		this.instances.put(targetPath, graphDatabaseService);
	}
	
	public void removeGraphDatabaseService(String targetPath) {
		this.instances.remove(targetPath);
	}
	
	public GraphDatabaseService getGraphDatabaseServiceByTargetPath(String targetPath) {
		return this.instances.get(targetPath);
	}
	
	public GraphDatabaseService getDefaultGraphDatabaseService() {
		return with(this.instances).values().first(anything());
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy