You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/02/12 14:01:51 UTC
[25/77] [partial] incubator-tinkerpop git commit: moved com/tinkerpop
directories to org/apache/tinkerpop
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/config/YamlConfiguration.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/config/YamlConfiguration.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/config/YamlConfiguration.java
deleted file mode 100644
index 77f80f2..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/config/YamlConfiguration.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.config;
-
-import org.apache.commons.configuration.AbstractHierarchicalFileConfiguration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.commons.configuration.tree.ConfigurationNode;
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-
-import java.io.File;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.URL;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-/**
- * Apache Commons Configuration object for YAML. Adapted from code originally found here:
- * https://github.com/PEXPlugins/SimpleConfigs
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class YamlConfiguration extends AbstractHierarchicalFileConfiguration {
- public final static int DEFAULT_IDENT = 4;
- private final DumperOptions yamlOptions = new DumperOptions();
- private final Yaml yaml = new Yaml(yamlOptions);
- private boolean xmlCompatibility = true;
-
- public YamlConfiguration() {
- super();
- initialize();
- }
-
- public YamlConfiguration(final HierarchicalConfiguration c) {
- super(c);
- initialize();
- }
-
- public YamlConfiguration(final String fileName) throws ConfigurationException {
- super(fileName);
- initialize();
- }
-
- public YamlConfiguration(final File file) throws ConfigurationException {
- super(file);
- initialize();
- }
-
- public YamlConfiguration(final URL url) throws ConfigurationException {
- super(url);
- initialize();
- }
-
- private void initialize() {
- yamlOptions.setIndent(DEFAULT_IDENT);
- yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
- }
-
- public void setXmlCompatibility(final boolean xmlCompatibility) {
- this.xmlCompatibility = xmlCompatibility;
- }
-
- @Override
- public void load(final Reader in) throws ConfigurationException {
- try {
- this.loadHierarchy(this.getRootNode(), yaml.load(in));
- } catch (Throwable e) {
- throw new ConfigurationException("Failed to load configuration: " + e.getMessage(), e);
- }
- }
-
- @Override
- public void save(final Writer out) throws ConfigurationException {
- try {
- yaml.dump(this.saveHierarchy(this.getRootNode()), out);
- } catch (Throwable e) {
- throw new ConfigurationException("Failed to save configuration: " + e.getMessage(), e);
- }
- }
-
- protected void loadHierarchy(final ConfigurationNode parentNode, final Object obj) {
- final String parentName = parentNode.getName();
- if (obj instanceof Map<?, ?>) {
- for (Map.Entry<String, Object> entry : ((Map<String, Object>) obj).entrySet()) {
- final Node childNode = new Node(entry.getKey());
-
- // if parent node is look like "tableS", "userS" or "groupS"
- if (this.xmlCompatibility && parentName != null && parentName.endsWith("s")) {
- //this is done to have "users.user[@name='smith'] instead of "users.smith"
- childNode.setName(parentName.substring(0, parentName.length() - 1));
- childNode.addAttribute(new Node("name", entry.getKey()));
- }
-
- childNode.setReference(entry);
- loadHierarchy(childNode, entry.getValue());
- parentNode.addChild(childNode);
- }
- } else if (obj instanceof Collection) {
- for (Object child : (Collection) obj) {
- final Node childNode = new Node("item");
- childNode.setReference(child);
- loadHierarchy(childNode, child);
- parentNode.addChild(childNode);
- }
- }
-
- parentNode.setValue(obj);
- }
-
- protected Object saveHierarchy(final ConfigurationNode parentNode) {
- if (parentNode.getChildrenCount() == 0)
- return parentNode.getValue();
-
- if (parentNode.getChildrenCount("item") == parentNode.getChildrenCount()) {
- return parentNode.getChildren().stream().map(this::saveHierarchy).collect(Collectors.toList());
- } else {
- final Map<String, Object> map = new LinkedHashMap<>();
- for (ConfigurationNode childNode : parentNode.getChildren()) {
- String nodeName = childNode.getName();
- if (this.xmlCompatibility && childNode.getAttributes("name").size() > 0)
- nodeName = String.valueOf(childNode.getAttributes("name").get(0).getValue());
-
-
- map.put(nodeName, saveHierarchy(childNode));
- }
-
- return map;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ArrayListSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ArrayListSupplier.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ArrayListSupplier.java
deleted file mode 100644
index ac694a9..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ArrayListSupplier.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.function.Supplier;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class ArrayListSupplier<A> implements Supplier<ArrayList<A>>, Serializable {
- private static final ArrayListSupplier INSTANCE = new ArrayListSupplier();
-
- private ArrayListSupplier() {
- }
-
- @Override
- public ArrayList<A> get() {
- return new ArrayList<>();
- }
-
- public static <A> ArrayListSupplier<A> instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/BulkSetSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/BulkSetSupplier.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/BulkSetSupplier.java
deleted file mode 100644
index 0c5d25c..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/BulkSetSupplier.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-import com.tinkerpop.gremlin.process.util.BulkSet;
-
-import java.io.Serializable;
-import java.util.function.Supplier;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class BulkSetSupplier<A> implements Supplier<BulkSet<A>>, Serializable {
- private static final BulkSetSupplier INSTANCE = new BulkSetSupplier();
-
- private BulkSetSupplier() {
- }
-
- @Override
- public BulkSet<A> get() {
- return new BulkSet<>();
- }
-
- public static <A> BulkSetSupplier<A> instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/CloningUnaryOperator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/CloningUnaryOperator.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/CloningUnaryOperator.java
deleted file mode 100644
index 51f9bf2..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/CloningUnaryOperator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.function.UnaryOperator;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class CloningUnaryOperator<A> implements UnaryOperator<A>, Serializable {
-
- private static final CloningUnaryOperator INSTANCE = new CloningUnaryOperator();
-
- private CloningUnaryOperator() {
- }
-
- @Override
- public A apply(final A a) {
- if (a instanceof HashMap)
- return (A) ((HashMap) a).clone();
- else if (a instanceof HashSet)
- return (A) ((HashSet) a).clone();
- else
- throw new IllegalArgumentException("The provided class is not registered for cloning: " + a.getClass());
- }
-
- public static <A> CloningUnaryOperator<A> instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ConstantSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ConstantSupplier.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ConstantSupplier.java
deleted file mode 100644
index 5f2ee81..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ConstantSupplier.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-import java.io.Serializable;
-import java.util.function.Supplier;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class ConstantSupplier<A> implements Supplier<A>, Serializable {
-
- private final A a;
-
- public ConstantSupplier(final A a) {
- this.a = a;
- }
-
- public A get() {
- return this.a;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/FunctionUtils.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/FunctionUtils.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/FunctionUtils.java
deleted file mode 100644
index 14e006e..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/FunctionUtils.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-import java.util.function.BiConsumer;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.function.Supplier;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public final class FunctionUtils {
- private FunctionUtils() {
- }
-
- public static <T, U> Function<T, U> wrapFunction(final ThrowingFunction<T, U> functionThatThrows) {
- return (a) -> {
- try {
- return functionThatThrows.apply(a);
- } catch (RuntimeException e) {
- throw e;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- };
- }
-
- public static <T> Consumer<T> wrapConsumer(final ThrowingConsumer<T> consumerThatThrows) {
- return (a) -> {
- try {
- consumerThatThrows.accept(a);
- } catch (RuntimeException e) {
- throw e;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- };
- }
-
- public static <T,U> BiConsumer<T,U> wrapBiConsumer(final ThrowingBiConsumer<T,U> consumerThatThrows) {
- return (a,b) -> {
- try {
- consumerThatThrows.accept(a,b);
- } catch (RuntimeException e) {
- throw e;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- };
- }
-
- public static <T> Supplier<T> wrapSupplier(final ThrowingSupplier<T> supplierThatThrows) {
- return () -> {
- try {
- return supplierThatThrows.get();
- } catch (RuntimeException e) {
- throw e;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashMapSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashMapSupplier.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashMapSupplier.java
deleted file mode 100644
index ca44bff..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashMapSupplier.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.function.Supplier;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class HashMapSupplier<K, V> implements Supplier<Map<K, V>>, Serializable {
-
- private static final HashMapSupplier INSTANCE = new HashMapSupplier();
-
- private HashMapSupplier() {
- }
-
- @Override
- public HashMap<K, V> get() {
- return new HashMap<>();
- }
-
- public static <K, V> HashMapSupplier<K, V> instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashSetSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashSetSupplier.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashSetSupplier.java
deleted file mode 100644
index 7447bef..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/HashSetSupplier.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-import java.io.Serializable;
-import java.util.HashSet;
-import java.util.function.Supplier;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class HashSetSupplier<A> implements Supplier<HashSet<A>>, Serializable {
- private static final HashSetSupplier INSTANCE = new HashSetSupplier();
-
- private HashSetSupplier() {
- }
-
- @Override
- public HashSet<A> get() {
- return new HashSet<>();
- }
-
- public static <A> HashSetSupplier<A> instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/MeanNumberSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/MeanNumberSupplier.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/MeanNumberSupplier.java
deleted file mode 100644
index ec94d16..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/MeanNumberSupplier.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-
-import com.tinkerpop.gremlin.process.graph.traversal.step.map.MeanStep;
-
-import java.io.Serializable;
-import java.util.function.Supplier;
-
-public final class MeanNumberSupplier implements Supplier<MeanStep.MeanNumber>, Serializable {
-
- private static final MeanNumberSupplier INSTANCE = new MeanNumberSupplier();
-
- private MeanNumberSupplier() {
-
- }
-
- @Override
- public MeanStep.MeanNumber get() {
- return new MeanStep.MeanNumber();
- }
-
- public static MeanNumberSupplier instance() {
- return INSTANCE;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingBiConsumer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingBiConsumer.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingBiConsumer.java
deleted file mode 100644
index ca4cf68..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingBiConsumer.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-@FunctionalInterface
-public interface ThrowingBiConsumer<A, B> {
- public void accept(final A a, final B b) throws Exception;
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingConsumer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingConsumer.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingConsumer.java
deleted file mode 100644
index db0ab12..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingConsumer.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-@FunctionalInterface
-public interface ThrowingConsumer<A> {
- public void accept(final A a) throws Exception;
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingFunction.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingFunction.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingFunction.java
deleted file mode 100644
index 86662a9..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingFunction.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-@FunctionalInterface
-public interface ThrowingFunction<T, R> {
- R apply(final T t) throws Exception;
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingSupplier.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingSupplier.java
deleted file mode 100644
index 57e93fe..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/ThrowingSupplier.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-@FunctionalInterface
-public interface ThrowingSupplier<T> {
- public T get() throws Exception;
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TraversableLambda.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TraversableLambda.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TraversableLambda.java
deleted file mode 100644
index 736866d..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TraversableLambda.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-import com.tinkerpop.gremlin.process.Traversal;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public interface TraversableLambda<S,E> extends Cloneable {
-
- public Traversal<S, E> getTraversal();
-
- public TraversableLambda clone() throws CloneNotSupportedException;
-
- public static <T> T tryAndClone(final Object object) throws CloneNotSupportedException {
- return (object instanceof TraversableLambda) ? (T) ((TraversableLambda) object).clone() : (T) object;
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TreeSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TreeSupplier.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TreeSupplier.java
deleted file mode 100644
index 4a599c1..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TreeSupplier.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-import com.tinkerpop.gremlin.process.graph.util.Tree;
-
-import java.io.Serializable;
-import java.util.function.Supplier;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class TreeSupplier<A> implements Supplier<Tree<A>>, Serializable {
- private static final TreeSupplier INSTANCE = new TreeSupplier();
-
- private TreeSupplier() {
- }
-
- @Override
- public Tree<A> get() {
- return new Tree<>();
- }
-
- public static <A> TreeSupplier<A> instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TriConsumer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TriConsumer.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TriConsumer.java
deleted file mode 100644
index 1f59d96..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TriConsumer.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-import java.util.Objects;
-
-/**
- * Represents an operation that accepts two input arguments and returns no result. This is the tri-arity
- * specialization of {@link java.util.function.Consumer}. Unlike most other functional interfaces, {@link TriConsumer}
- * is expected to operate via side-effects.
- * <p/>
- * This is a functional interface whose functional method is {@link #accept(Object, Object, Object)}.
- *
- * @param <A> the type of the first argument to the operation
- * @param <B> the type of the second argument to the operation
- * @param <C> the type of the third argument to the operation
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public interface TriConsumer<A, B, C> {
-
- /**
- * Performs this operation on the given arguments.
- *
- * @param a the first argument to the operation
- * @param b the second argument to the operation
- * @param c the third argument to the operation
- */
- public void accept(final A a, final B b, final C c);
-
- /**
- * Returns a composed @{link TriConsumer} that performs, in sequence, this operation followed by the {@code after}
- * operation. If performing either operation throws an exception, it is relayed to the caller of the composed
- * operation. If performing this operation throws an exception, the after operation will not be performed.
- *
- * @param after the operation to perform after this operation
- * @return a composed {@link TriConsumer} that performs in sequence this operation followed by the {@code after}
- * operation
- * @throws NullPointerException if {@code after} is null
- */
- public default TriConsumer<A, B, C> andThen(final TriConsumer<? super A, ? super B, ? super C> after) {
- Objects.requireNonNull(after);
- return (A a, B b, C c) -> {
- accept(a, b, c);
- after.accept(a, b, c);
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TriFunction.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TriFunction.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TriFunction.java
deleted file mode 100644
index 55ffe1e..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/function/TriFunction.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.function;
-
-import java.util.Objects;
-import java.util.function.Function;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public interface TriFunction<A, B, C, R> {
-
- /**
- * Applies this function to the given arguments.
- *
- * @param a the first argument to the function
- * @param b the second argument to the function
- * @param c the third argument to the function
- * @return the function result
- */
- public R apply(final A a, final B b, final C c);
-
- /**
- * Returns a composed function that first applies this function to its input, and then applies the after function
- * to the result. If evaluation of either function throws an exception, it is relayed to the caller of the composed
- * function.
- *
- * @param after the function to apply after this function is applied
- * @param <V> the type of the output of the {@code after} function, and of the composed function
- * @return a composed function that first applies this function and then applies the {@code after} function.
- * @throws NullPointerException if {@code after} is null
- */
- public default <V> TriFunction<A, B, C, V> andThen(final Function<? super R, ? extends V> after) {
- Objects.requireNonNull(after);
- return (A a, B b, C c) -> after.apply(apply(a, b, c));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/ArrayIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/ArrayIterator.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/ArrayIterator.java
deleted file mode 100644
index 42a73c0..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/ArrayIterator.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.iterator;
-
-import com.tinkerpop.gremlin.process.FastNoSuchElementException;
-
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.Iterator;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class ArrayIterator<T> implements Iterator<T>, Serializable {
-
- private final T[] array;
- private int current = 0;
-
- public ArrayIterator(final T[] array) {
- this.array = array;
- }
-
- @Override
- public boolean hasNext() {
- return this.current < this.array.length;
- }
-
- @Override
- public T next() {
- if (this.hasNext()) {
- this.current++;
- return this.array[this.current - 1];
- } else {
- throw FastNoSuchElementException.instance();
- }
- }
-
- @Override
- public String toString() {
- return Arrays.asList(array).toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/DoubleIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/DoubleIterator.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/DoubleIterator.java
deleted file mode 100644
index 840ccdf..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/DoubleIterator.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.iterator;
-
-import com.tinkerpop.gremlin.process.FastNoSuchElementException;
-
-import java.io.Serializable;
-import java.util.Iterator;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-final class DoubleIterator<T> implements Iterator<T>, Serializable {
-
- private final T a;
- private final T b;
- private char current = 'a';
-
- protected DoubleIterator(final T a, final T b) {
- this.a = a;
- this.b = b;
- }
-
- @Override
- public boolean hasNext() {
- return this.current != 'x';
- }
-
- @Override
- public T next() {
- if (this.current == 'x')
- throw FastNoSuchElementException.instance();
- else {
- if (this.current == 'a') {
- this.current = 'b';
- return this.a;
- } else {
- this.current = 'x';
- return this.b;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/EmptyIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/EmptyIterator.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/EmptyIterator.java
deleted file mode 100644
index af7f312..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/EmptyIterator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.iterator;
-
-import com.tinkerpop.gremlin.process.FastNoSuchElementException;
-
-import java.io.Serializable;
-import java.util.Iterator;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class EmptyIterator<S> implements Iterator<S>, Serializable {
-
- private static final EmptyIterator INSTANCE = new EmptyIterator<>();
-
- private EmptyIterator() {
- }
-
- @Override
- public boolean hasNext() {
- return false;
- }
-
- @Override
- public S next() {
- throw FastNoSuchElementException.instance();
- }
-
- public static <S> Iterator<S> instance() {
- return INSTANCE;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/IteratorUtils.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/IteratorUtils.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/IteratorUtils.java
deleted file mode 100644
index e01ecc0..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/IteratorUtils.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.iterator;
-
-import com.tinkerpop.gremlin.process.FastNoSuchElementException;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import java.util.stream.Stream;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class IteratorUtils {
-
- private IteratorUtils() {
-
- }
-
- public static final <S> Iterator<S> of(final S a) {
- return new SingleIterator<>(a);
- }
-
- public static final <S> Iterator<S> of(final S a, S b) {
- return new DoubleIterator<>(a, b);
- }
-
- ///////////////
-
- public static Iterator convertToIterator(final Object o) {
- final Iterator itty;
- if (o instanceof Iterable)
- itty = ((Iterable) o).iterator();
- else if (o instanceof Iterator)
- itty = (Iterator) o;
- else if (o instanceof Object[])
- itty = new ArrayIterator<>((Object[]) o);
- else if (o instanceof Stream)
- itty = ((Stream) o).iterator();
- else if (o instanceof Map)
- itty = ((Map) o).entrySet().iterator();
- else if (o instanceof Throwable)
- itty = IteratorUtils.of(((Throwable) o).getMessage());
- else
- itty = IteratorUtils.of(o);
- return itty;
- }
-
- public static List convertToList(final Object o) {
- final Iterator iterator = IteratorUtils.convertToIterator(o);
- return list(iterator);
- }
-
- public static final <S extends Collection<T>, T> S fill(final Iterator<T> iterator, final S collection) {
- while (iterator.hasNext()) {
- collection.add(iterator.next());
- }
- return collection;
- }
-
- public static final long count(final Iterator iterator) {
- long ix = 0;
- for (; iterator.hasNext(); ++ix) iterator.next();
- return ix;
- }
-
- public static <S> List<S> list(final Iterator<S> iterator) {
- return fill(iterator, new ArrayList<>());
- }
-
- public static <K, S> Map<K, S> collectMap(final Iterator<S> iterator, final Function<S, K> key) {
- return collectMap(iterator, key, Function.identity());
- }
-
- public static <K, S, V> Map<K, V> collectMap(final Iterator<S> iterator, final Function<S, K> key, final Function<S, V> value) {
- final Map<K, V> map = new HashMap<>();
- while (iterator.hasNext()) {
- final S obj = iterator.next();
- map.put(key.apply(obj), value.apply(obj));
- }
- return map;
- }
-
- public static <K, S> Map<K, List<S>> groupBy(final Iterator<S> iterator, final Function<S, K> groupBy) {
- final Map<K, List<S>> map = new HashMap<>();
- while (iterator.hasNext()) {
- final S obj = iterator.next();
- map.computeIfAbsent(groupBy.apply(obj), k -> new ArrayList<>()).add(obj);
- }
- return map;
- }
-
- ///////////////
-
- public static final <S, E> Iterator<E> map(final Iterator<S> iterator, final Function<S, E> function) {
- return new Iterator<E>() {
- @Override
- public boolean hasNext() {
- return iterator.hasNext();
- }
-
- @Override
- public E next() {
- return function.apply(iterator.next());
- }
- };
- }
-
- public static final <S, E> Iterable<E> map(final Iterable<S> iterable, final Function<S, E> function) {
- return new Iterable<E>() {
- @Override
- public Iterator<E> iterator() {
- return IteratorUtils.map(iterable.iterator(), function);
- }
- };
- }
-
- ///////////////
-
- public static final <S> Iterator<S> filter(final Iterator<S> iterator, final Predicate<S> predicate) {
-
-
- return new Iterator<S>() {
- S nextResult = null;
-
- @Override
- public boolean hasNext() {
- if (null != this.nextResult) {
- return true;
- } else {
- advance();
- return null != this.nextResult;
- }
- }
-
- @Override
- public S next() {
- try {
- if (null != this.nextResult) {
- return this.nextResult;
- } else {
- advance();
- if (null != this.nextResult)
- return this.nextResult;
- else
- throw FastNoSuchElementException.instance();
- }
- } finally {
- this.nextResult = null;
- }
- }
-
- private final void advance() {
- this.nextResult = null;
- while (iterator.hasNext()) {
- final S s = iterator.next();
- if (predicate.test(s)) {
- this.nextResult = s;
- return;
- }
- }
- }
- };
- }
-
- public static final <S> Iterable<S> filter(final Iterable<S> iterable, final Predicate<S> predicate) {
- return new Iterable<S>() {
- @Override
- public Iterator<S> iterator() {
- return IteratorUtils.filter(iterable.iterator(), predicate);
- }
- };
- }
-
- ///////////////////
-
- public static final <S> Iterator<S> concat(final Iterator<S>... iterators) {
- final MultiIterator<S> iterator = new MultiIterator<>();
- for (final Iterator<S> itty : iterators) {
- iterator.addIterator(itty);
- }
- return iterator;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/MultiIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/MultiIterator.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/MultiIterator.java
deleted file mode 100644
index c5dca2d..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/MultiIterator.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.iterator;
-
-import com.tinkerpop.gremlin.process.FastNoSuchElementException;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class MultiIterator<T> implements Iterator<T>, Serializable {
-
- private final List<Iterator<T>> iterators = new ArrayList<>();
- private int current = 0;
-
- public void addIterator(final Iterator<T> iterator) {
- this.iterators.add(iterator);
- }
-
- @Override
- public boolean hasNext() {
- if (this.current >= this.iterators.size())
- return false;
-
- Iterator<T> currentIterator = iterators.get(this.current);
-
- while (true) {
- if (currentIterator.hasNext()) {
- return true;
- } else {
- this.current++;
- if (this.current >= iterators.size())
- break;
- currentIterator = iterators.get(this.current);
- }
- }
- return false;
- }
-
- @Override
- public T next() {
- Iterator<T> currentIterator = iterators.get(this.current);
- while (true) {
- if (currentIterator.hasNext()) {
- return currentIterator.next();
- } else {
- this.current++;
- if (this.current >= iterators.size())
- break;
- currentIterator = iterators.get(current);
- }
- }
- throw FastNoSuchElementException.instance();
- }
-
- public void clear() {
- this.iterators.clear();
- this.current = 0;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/SingleIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/SingleIterator.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/SingleIterator.java
deleted file mode 100644
index 178c6a9..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/iterator/SingleIterator.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.iterator;
-
-import com.tinkerpop.gremlin.process.FastNoSuchElementException;
-
-import java.io.Serializable;
-import java.util.Iterator;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-final class SingleIterator<T> implements Iterator<T>,Serializable {
-
- private final T t;
- private boolean alive = true;
-
- protected SingleIterator(final T t) {
- this.t = t;
- }
-
- @Override
- public boolean hasNext() {
- return this.alive;
- }
-
- @Override
- public T next() {
- if (!this.alive)
- throw FastNoSuchElementException.instance();
- else {
- this.alive = false;
- return t;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/tools/MultiMap.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/tools/MultiMap.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/tools/MultiMap.java
deleted file mode 100644
index 22d377d..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/tools/MultiMap.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.tools;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A number of static methods to interact with a multi map, i.e. a map that maps keys to sets of values.
- *
- * @author Matthias Broecheler (me@matthiasb.com)
- */
-public class MultiMap {
-
- public static <K, V> boolean putAll(final Map<K, Set<V>> map, final K key, final Collection<V> values) {
- return getMapSet(map, key).addAll(values);
- }
-
- public static <K, V> boolean put(final Map<K, Set<V>> map, final K key, final V value) {
- return getMapSet(map, key).add(value);
- }
-
- public static <K, V> boolean containsEntry(final Map<K, Set<V>> map, final K key, final V value) {
- final Set<V> set = map.get(key);
- return set != null && set.contains(value);
- }
-
- public static <K, V> Set<V> get(final Map<K, Set<V>> map, final K key) {
- final Set<V> set = getMapSet(map, key);
- return set == null ? Collections.emptySet() : set;
- }
-
- private static <K, V> Set<V> getMapSet(final Map<K, Set<V>> map, final K key) {
- Set<V> set = map.get(key);
- if (set == null) {
- set = new HashSet<>();
- map.put(key, set);
- }
- return set;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/tools/TimeUtils.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/tools/TimeUtils.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/tools/TimeUtils.java
deleted file mode 100644
index 030e615..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/util/tools/TimeUtils.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.tinkerpop.gremlin.util.tools;
-
-import java.util.stream.IntStream;
-
-/**
- * @author Daniel Kuppitz (http://gremlin.guru)
- */
-public class TimeUtils {
-
- public static double clock(final Runnable runnable) {
- return clock(100, runnable);
- }
-
- public static double clock(final int loops, final Runnable runnable) {
- runnable.run(); // warm-up
- return IntStream.range(0, loops).mapToDouble(i -> {
- long t = System.nanoTime();
- runnable.run();
- return (System.nanoTime() - t) * 0.000001;
- }).sum() / loops;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/FastNoSuchElementException.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/FastNoSuchElementException.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/FastNoSuchElementException.java
new file mode 100644
index 0000000..0773791
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/FastNoSuchElementException.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.process;
+
+import java.util.NoSuchElementException;
+
+/**
+ * Retrieve a singleton, fast {@link java.util.NoSuchElementException} without a stack trace.
+ */
+public final class FastNoSuchElementException extends NoSuchElementException {
+
+ private static final long serialVersionUID = 2303108654138257697L;
+ private static final FastNoSuchElementException INSTANCE = new FastNoSuchElementException();
+
+ private FastNoSuchElementException() {
+ }
+
+ /**
+ * Retrieve a singleton, fast {@link NoSuchElementException} without a stack trace.
+ */
+ public static NoSuchElementException instance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public synchronized Throwable fillInStackTrace() {
+ return this;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/Path.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/Path.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/Path.java
new file mode 100644
index 0000000..f892401
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/Path.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.process;
+
+import org.javatuples.Pair;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+
+/**
+ * A Path denotes a particular walk through a {@link com.tinkerpop.gremlin.structure.Graph} as defined by a {@link Traverser}.
+ * In abstraction, any Path implementation maintains two lists: a list of sets of labels and a list of objects.
+ * The list of labels are the labels of the steps traversed.
+ * The list of objects are the objects traversed.
+ *
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface Path extends Cloneable {
+
+ /**
+ * Get the number of step in the path.
+ *
+ * @return the size of the path
+ */
+ public default int size() {
+ return this.objects().size();
+ }
+
+ /**
+ * Add a new step to the path with an object and any number of associated labels.
+ *
+ * @param object the new head of the path
+ * @param labels the labels at the head of the path
+ * @return the extended path
+ */
+ public Path extend(final Object object, final String... labels);
+
+ /**
+ * Get the object associated with the particular label of the path.
+ * If the path as multiple labels of the type, then return a {@link List} of those objects.
+ *
+ * @param label the label of the path
+ * @param <A> the type of the object associated with the label
+ * @return the object associated with the label of the path
+ * @throws IllegalArgumentException if the path does not contain the label
+ */
+ public default <A> A get(final String label) throws IllegalArgumentException {
+ final List<Object> objects = this.objects();
+ final List<Set<String>> labels = this.labels();
+ Object object = null;
+ for (int i = 0; i < labels.size(); i++) {
+ if (labels.get(i).contains(label)) {
+ if (null == object) {
+ object = objects.get(i);
+ } else if (object instanceof List) {
+ ((List) object).add(objects.get(i));
+ } else {
+ final List list = new ArrayList(2);
+ list.add(object);
+ list.add(objects.get(i));
+ object = list;
+ }
+ }
+ }
+ if (null == object)
+ throw Path.Exceptions.stepWithProvidedLabelDoesNotExist(label);
+ return (A) object;
+ }
+
+ /**
+ * Get the object associated with the specified index into the path.
+ *
+ * @param index the index of the path
+ * @param <A> the type of the object associated with the index
+ * @return the object associated with the index of the path
+ */
+ public default <A> A get(final int index) {
+ return (A) this.objects().get(index);
+ }
+
+ /**
+ * Return true if the path has the specified label, else return false.
+ *
+ * @param label the label to search for
+ * @return true if the label exists in the path
+ */
+ public default boolean hasLabel(final String label) {
+ return this.labels().stream().filter(labels -> labels.contains(label)).findAny().isPresent();
+ }
+
+ /**
+ * Add label to the current head of the path.
+ *
+ * @param label the label to add to the head of the path
+ */
+ public void addLabel(final String label);
+
+ /**
+ * An ordered list of the objects in the path.
+ *
+ * @return the objects of the path
+ */
+ public List<Object> objects();
+
+ /**
+ * An ordered list of the labels associated with the path
+ *
+ * @return the labels of the path
+ */
+ public List<Set<String>> labels();
+
+ /**
+ * {@inheritDoc}
+ */
+ public Path clone() throws CloneNotSupportedException;
+
+ /**
+ * Determines whether the path is a simple or not.
+ * A simple path has no cycles and thus, no repeated objects.
+ *
+ * @return Whether the path is simple or not
+ */
+ public default boolean isSimple() {
+ final List<Object> objects = this.objects();
+ for (int i = 0; i < objects.size() - 1; i++) {
+ for (int j = i + 1; j < objects.size(); j++) {
+ if (objects.get(i).equals(objects.get(j)))
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public default void forEach(final Consumer<Object> consumer) {
+ this.objects().forEach(consumer);
+ }
+
+ public default void forEach(final BiConsumer<Object, Set<String>> consumer) {
+ final List<Object> objects = this.objects();
+ final List<Set<String>> labels = this.labels();
+ for (int i = 0; i < objects.size(); i++) {
+ consumer.accept(objects.get(i), labels.get(i));
+ }
+ }
+
+ public default Stream<Pair<Object, Set<String>>> stream() {
+ final List<Set<String>> labels = this.labels();
+ final List<Object> objects = this.objects();
+ return IntStream.range(0, this.size()).mapToObj(i -> Pair.with(objects.get(i), labels.get(i)));
+ }
+
+ public static class Exceptions {
+
+ public static IllegalArgumentException stepWithProvidedLabelDoesNotExist(final String label) {
+ return new IllegalArgumentException("The step with label " + label + " does not exist");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/Scope.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/Scope.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/Scope.java
new file mode 100644
index 0000000..3bf881d
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/Scope.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.process;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public enum Scope {
+
+ global, local
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/Step.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/Step.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/Step.java
new file mode 100644
index 0000000..b197790
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/Step.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.process;
+
+import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * A {@link Step} denotes a unit of computation within a {@link Traversal}.
+ * A step takes an incoming object and yields an outgoing object.
+ * Steps are chained together in a {@link Traversal} to yield a lazy function chain of computation.
+ * <p/>
+ * In the constructor of a Step, never store explicit sideEffect objects in {@link TraversalSideEffects}.
+ * If a sideEffect needs to be registered with the {@link Traversal}, use SideEffects.registerSupplier().
+ *
+ * @param <S> The incoming object type of the step
+ * @param <E> The outgoing object type of the step
+ */
+public interface Step<S, E> extends Iterator<Traverser<E>>, Serializable, Cloneable {
+
+ /**
+ * Add a iterator of {@link Traverser} objects of type S to the step.
+ *
+ * @param starts The iterator of objects to add
+ */
+ public void addStarts(final Iterator<Traverser<S>> starts);
+
+ /**
+ * Add a single {@link Traverser} to the step.
+ *
+ * @param start The traverser to add
+ */
+ public void addStart(final Traverser<S> start);
+
+ /**
+ * Set the step that is previous to the current step.
+ * Used for linking steps together to form a function chain.
+ *
+ * @param step the previous step of this step
+ */
+ public void setPreviousStep(final Step<?, S> step);
+
+ /**
+ * Get the step prior to the current step.
+ *
+ * @return The previous step
+ */
+ public Step<?, S> getPreviousStep();
+
+ /**
+ * Set the step that is next to the current step.
+ * Used for linking steps together to form a function chain.
+ *
+ * @param step the next step of this step
+ */
+ public void setNextStep(final Step<E, ?> step);
+
+ /**
+ * Get the next step to the current step.
+ *
+ * @return The next step
+ */
+ public Step<E, ?> getNextStep();
+
+ /**
+ * Get the {@link Traversal.Admin} that this step is contained within.
+ *
+ * @param <A> The incoming object type of the traversal
+ * @param <B> The outgoing object type of the traversal
+ * @return The traversal of this step
+ */
+ public <A, B> Traversal.Admin<A, B> getTraversal();
+
+ /**
+ * Set the {@link Traversal} that this step is contained within.
+ *
+ * @param traversal the new traversal for this step
+ */
+ public void setTraversal(final Traversal.Admin<?, ?> traversal);
+
+ /**
+ * Reset the state of the step such that it has no incoming starts.
+ * Internal states are to be reset, but any sideEffect data structures are not to be recreated.
+ */
+ public void reset();
+
+ /**
+ * Cloning is used to duplicate steps for the purpose of traversal optimization and OLTP replication.
+ * When cloning a step, it is important that the steps, the cloned step is equivalent to the state of the step when reset() is called.
+ * Moreover, the previous and next steps should be set to {@link com.tinkerpop.gremlin.process.traversal.step.EmptyStep}.
+ *
+ * @return The cloned step
+ * @throws CloneNotSupportedException
+ */
+ public Step<S, E> clone() throws CloneNotSupportedException;
+
+ /**
+ * Get the label of this step.
+ * If the step is not labeled, then an {@link Optional#empty} is returned.
+ *
+ * @return the optional label of the step
+ */
+ public Optional<String> getLabel();
+
+ /**
+ * Set the label of this step.
+ *
+ * @param label the label for this step
+ */
+ public void setLabel(final String label);
+
+ /**
+ * Get the unique id of the step.
+ * These ids can change when strategies are applied and anonymous traversals are embedded in the parent traversal.
+ * A developer should typically not need to call this method.
+ *
+ * @param id the unique id of the step
+ */
+ public void setId(final String id);
+
+ /**
+ * Get the unique id of this step.
+ *
+ * @return the unique id of the step
+ */
+ public String getId();
+
+ /**
+ * Provide the necessary {@link com.tinkerpop.gremlin.process.traverser.TraverserRequirement} that must be met by the traverser in order for the step to function properly.
+ * The provided default implements returns an empty set.
+ *
+ * @return the set of requirements
+ */
+ public default Set<TraverserRequirement> getRequirements() {
+ return Collections.emptySet();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/T.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/T.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/T.java
new file mode 100644
index 0000000..9039300
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/T.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.tinkerpop.gremlin.process;
+
+import com.tinkerpop.gremlin.structure.Element;
+import com.tinkerpop.gremlin.structure.Graph;
+import com.tinkerpop.gremlin.structure.VertexProperty;
+
+import java.util.function.Function;
+
+/**
+ * A collection of (T)okens which allows for more concise Traversal definitions.
+ * T implements {@link Function} can be used to map an element to its token value.
+ * For example, <code>T.id.apply(element)</code>.
+ *
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public enum T implements Function<Element, Object> {
+ /**
+ * Label (representing Element.label())
+ */
+ label {
+ @Override
+ public String getAccessor() {
+ return LABEL;
+ }
+
+ @Override
+ public String apply(final Element element) {
+ return element.label();
+ }
+ },
+ /**
+ * Id (representing Element.id())
+ */
+ id {
+ @Override
+ public String getAccessor() {
+ return ID;
+ }
+
+ @Override
+ public Object apply(final Element element) {
+ return element.id();
+ }
+ },
+ /**
+ * Key (representing Property.key())
+ */
+ key {
+ @Override
+ public String getAccessor() {
+ return KEY;
+ }
+
+ @Override
+ public String apply(final Element element) {
+ return ((VertexProperty) element).key();
+ }
+ },
+ /**
+ * Value (representing Property.value())
+ */
+ value {
+ @Override
+ public String getAccessor() {
+ return VALUE;
+ }
+
+ @Override
+ public Object apply(final Element element) {
+ return ((VertexProperty) element).value();
+ }
+ };
+
+ private static final String LABEL = Graph.Hidden.hide("label");
+ private static final String ID = Graph.Hidden.hide("id");
+ private static final String KEY = Graph.Hidden.hide("key");
+ private static final String VALUE = Graph.Hidden.hide("value");
+
+ public abstract String getAccessor();
+
+ @Override
+ public abstract Object apply(final Element element);
+
+ public static T fromString(final String accessor) {
+ if (accessor.equals(LABEL))
+ return label;
+ else if (accessor.equals(ID))
+ return id;
+ else if (accessor.equals(KEY))
+ return key;
+ else if (accessor.equals(VALUE))
+ return value;
+ else
+ throw new IllegalArgumentException("The following token string is unknown: " + accessor);
+ }
+}