Search in sources :

Example 1 with Module

use of com.tinkerpop.frames.modules.Module in project frames by tinkerpop.

the class FramedGraphFactory method getConfiguration.

/**
 * Returns a configuration that can be used when constructing a framed graph.
 * @param requiredType The type of graph required after configuration e.g. {@link TransactionalGraph}
 * @param baseGraph The base graph to get a configuration for.
 * @return The configuration.
 */
protected <T extends Graph> FramedGraphConfiguration getConfiguration(Class<T> requiredType, T baseGraph) {
    Graph configuredGraph = baseGraph;
    FramedGraphConfiguration config = getBaseConfig();
    for (Module module : modules) {
        configuredGraph = module.configure(configuredGraph, config);
        if (!(requiredType.isInstance(configuredGraph))) {
            throw new UnsupportedOperationException("Module '" + module.getClass() + "' returned a '" + baseGraph.getClass().getName() + "' but factory requires '" + requiredType.getName() + "'");
        }
    }
    config.setConfiguredGraph(configuredGraph);
    return config;
}
Also used : Graph(com.tinkerpop.blueprints.Graph) TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph) Module(com.tinkerpop.frames.modules.Module)

Aggregations

Graph (com.tinkerpop.blueprints.Graph)1 TransactionalGraph (com.tinkerpop.blueprints.TransactionalGraph)1 Module (com.tinkerpop.frames.modules.Module)1