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

com.tinkerpop.gremlin.structure.util.EmptyGraph Maven / Gradle / Ivy

package com.tinkerpop.gremlin.structure.util;

import com.tinkerpop.gremlin.process.Traversal;
import com.tinkerpop.gremlin.process.computer.GraphComputer;
import com.tinkerpop.gremlin.process.graph.GraphTraversal;
import com.tinkerpop.gremlin.process.util.EmptyTraversal;
import com.tinkerpop.gremlin.structure.Edge;
import com.tinkerpop.gremlin.structure.Graph;
import com.tinkerpop.gremlin.structure.Transaction;
import com.tinkerpop.gremlin.structure.Vertex;

/**
 * @author Marko A. Rodriguez (http://markorodriguez.com)
 */
public class EmptyGraph implements Graph {

    private static final String MESSAGE = "The graph is immutable and empty";
    private static final EmptyGraph INSTANCE = new EmptyGraph();

    private EmptyGraph() {

    }

    @Override
    public GraphTraversal V() {
        return (GraphTraversal) EmptyTraversal.instance();
    }

    @Override
    public GraphTraversal E() {
        return (GraphTraversal) EmptyTraversal.instance();
    }

    @Override
    public , S> T of(final Class traversal) {
        return (T) EmptyTraversal.instance();
    }

    @Override
    public  GraphTraversal of() {
        return (GraphTraversal) EmptyTraversal.instance();
    }

    public static Graph instance() {
        return INSTANCE;
    }

    @Override
    public Vertex addVertex(Object... keyValues) {
        throw new IllegalStateException(MESSAGE);
    }

    @Override
    public GraphComputer compute(final Class... graphComputerClass) {
        throw new IllegalStateException(MESSAGE);
    }

    @Override
    public Transaction tx() {
        throw new IllegalStateException(MESSAGE);
    }

    @Override
    public Variables variables() {
        throw new IllegalStateException(MESSAGE);
    }

    @Override
    public void close() throws Exception {
        throw new IllegalStateException(MESSAGE);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy