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

overflowdb.tinkerpop.GraphVariables Maven / Gradle / Ivy

There is a newer version: 1.115
Show newest version
package overflowdb.tinkerpop;

import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.util.GraphVariableHelper;
import org.apache.tinkerpop.gremlin.structure.util.StringFactory;

import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

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

  private final Map variables = new ConcurrentHashMap<>();

  public GraphVariables() {

  }

  @Override
  public Set keys() {
    return this.variables.keySet();
  }

  @Override
  public  Optional get(final String key) {
    return Optional.ofNullable((R) this.variables.get(key));
  }

  @Override
  public void remove(final String key) {
    this.variables.remove(key);
  }

  @Override
  public void set(final String key, final Object value) {
    GraphVariableHelper.validateVariable(key, value);
    this.variables.put(key, value);
  }

  public String toString() {
    return StringFactory.graphVariablesString(this);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy