当前位置: 首页>>代码示例>>Java>>正文


Java Direction.equals方法代码示例

本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.Direction.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Direction.equals方法的具体用法?Java Direction.equals怎么用?Java Direction.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tinkerpop.gremlin.structure.Direction的用法示例。


在下文中一共展示了Direction.equals方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEdges

import org.apache.tinkerpop.gremlin.structure.Direction; //导入方法依赖的package包/类
public static Iterator<TinkerEdge> getEdges(final TinkerVertex vertex, final Direction direction, final String... edgeLabels) {
    final List<Edge> edges = new ArrayList<>();
    if (direction.equals(Direction.OUT) || direction.equals(Direction.BOTH)) {
        if (vertex.outEdges != null) {
            if (edgeLabels.length == 0)
                vertex.outEdges.values().forEach(edges::addAll);
            else if (edgeLabels.length == 1)
                edges.addAll(vertex.outEdges.getOrDefault(edgeLabels[0], Collections.emptySet()));
            else
                Stream.of(edgeLabels).map(vertex.outEdges::get).filter(Objects::nonNull).forEach(edges::addAll);
        }
    }
    if (direction.equals(Direction.IN) || direction.equals(Direction.BOTH)) {
        if (vertex.inEdges != null) {
            if (edgeLabels.length == 0)
                vertex.inEdges.values().forEach(edges::addAll);
            else if (edgeLabels.length == 1)
                edges.addAll(vertex.inEdges.getOrDefault(edgeLabels[0], Collections.emptySet()));
            else
                Stream.of(edgeLabels).map(vertex.inEdges::get).filter(Objects::nonNull).forEach(edges::addAll);
        }
    }
    return (Iterator) edges.iterator();
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:25,代码来源:TinkerHelper.java

示例2: getVertices

import org.apache.tinkerpop.gremlin.structure.Direction; //导入方法依赖的package包/类
public static Iterator<TinkerVertex> getVertices(final TinkerVertex vertex, final Direction direction, final String... edgeLabels) {
    final List<Vertex> vertices = new ArrayList<>();
    if (direction.equals(Direction.OUT) || direction.equals(Direction.BOTH)) {
        if (vertex.outEdges != null) {
            if (edgeLabels.length == 0)
                vertex.outEdges.values().forEach(set -> set.forEach(edge -> vertices.add(((TinkerEdge) edge).inVertex)));
            else if (edgeLabels.length == 1)
                vertex.outEdges.getOrDefault(edgeLabels[0], Collections.emptySet()).forEach(edge -> vertices.add(((TinkerEdge) edge).inVertex));
            else
                Stream.of(edgeLabels).map(vertex.outEdges::get).filter(Objects::nonNull).flatMap(Set::stream).forEach(edge -> vertices.add(((TinkerEdge) edge).inVertex));
        }
    }
    if (direction.equals(Direction.IN) || direction.equals(Direction.BOTH)) {
        if (vertex.inEdges != null) {
            if (edgeLabels.length == 0)
                vertex.inEdges.values().forEach(set -> set.forEach(edge -> vertices.add(((TinkerEdge) edge).outVertex)));
            else if (edgeLabels.length == 1)
                vertex.inEdges.getOrDefault(edgeLabels[0], Collections.emptySet()).forEach(edge -> vertices.add(((TinkerEdge) edge).outVertex));
            else
                Stream.of(edgeLabels).map(vertex.inEdges::get).filter(Objects::nonNull).flatMap(Set::stream).forEach(edge -> vertices.add(((TinkerEdge) edge).outVertex));
        }
    }
    return (Iterator) vertices.iterator();
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:25,代码来源:TinkerHelper.java

示例3: readEdges

import org.apache.tinkerpop.gremlin.structure.Direction; //导入方法依赖的package包/类
private <I extends InputShim> void readEdges(final KryoShim<I, ?> kryo, final I input, final StarGraph starGraph, final Direction direction) {
    if (kryo.readObject(input, Boolean.class)) {
        final int numberOfUniqueLabels = kryo.readObject(input, Integer.class);
        for (int i = 0; i < numberOfUniqueLabels; i++) {
            final String edgeLabel = kryo.readObject(input, String.class);
            final int numberOfEdgesWithLabel = kryo.readObject(input, Integer.class);
            for (int j = 0; j < numberOfEdgesWithLabel; j++) {
                final Object edgeId = kryo.readClassAndObject(input);
                final Object adjacentVertexId = kryo.readClassAndObject(input);
                if (this.graphFilter.checkEdgeLegality(direction, edgeLabel).positive()) {
                    if (direction.equals(Direction.OUT))
                        starGraph.starVertex.addOutEdge(edgeLabel, starGraph.addVertex(T.id, adjacentVertexId), T.id, edgeId);
                    else
                        starGraph.starVertex.addInEdge(edgeLabel, starGraph.addVertex(T.id, adjacentVertexId), T.id, edgeId);
                } else if (null != starGraph.edgeProperties) {
                    starGraph.edgeProperties.remove(edgeId);
                }
            }
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:22,代码来源:StarGraphSerializer.java

示例4: edges

import org.apache.tinkerpop.gremlin.structure.Direction; //导入方法依赖的package包/类
@Override
public Iterator<Edge> edges(final Direction direction, final String... edgeLabels) {
    if (direction.equals(Direction.OUT)) {
        return null == this.outEdges ? Collections.emptyIterator() : edgeLabels.length == 0 ?
                IteratorUtils.flatMap(this.outEdges.values().iterator(), List::iterator) :
                this.outEdges.entrySet().stream()
                        .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels))
                        .map(Map.Entry::getValue)
                        .flatMap(List::stream)
                        .iterator();
    } else if (direction.equals(Direction.IN)) {
        return null == this.inEdges ? Collections.emptyIterator() : edgeLabels.length == 0 ?
                IteratorUtils.flatMap(this.inEdges.values().iterator(), List::iterator) :
                this.inEdges.entrySet().stream()
                        .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels))
                        .map(Map.Entry::getValue)
                        .flatMap(List::stream)
                        .iterator();
    } else
        return IteratorUtils.concat(this.edges(Direction.IN, edgeLabels), this.edges(Direction.OUT, edgeLabels));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:22,代码来源:StarGraph.java

示例5: addE

import org.apache.tinkerpop.gremlin.structure.Direction; //导入方法依赖的package包/类
/**
 * @deprecated As of release 3.1.0, replaced by {@link #addE(String)}
 */
@Deprecated
public default GraphTraversal<S, Edge> addE(final Direction direction, final String firstVertexKeyOrEdgeLabel, final String edgeLabelOrSecondVertexKey, final Object... propertyKeyValues) {
    if (propertyKeyValues.length % 2 == 0) {
        // addOutE("createdBy", "a")
        this.addE(firstVertexKeyOrEdgeLabel);
        if (direction.equals(Direction.OUT))
            this.to(edgeLabelOrSecondVertexKey);
        else
            this.from(edgeLabelOrSecondVertexKey);
        ((Mutating) this.asAdmin().getEndStep()).addPropertyMutations(propertyKeyValues);
        return (GraphTraversal<S, Edge>) this;
    } else {
        // addInE("a", "codeveloper", "b", "year", 2009)
        this.addE(edgeLabelOrSecondVertexKey);
        if (direction.equals(Direction.OUT))
            this.from(firstVertexKeyOrEdgeLabel).to((String) propertyKeyValues[0]);
        else
            this.to(firstVertexKeyOrEdgeLabel).from((String) propertyKeyValues[0]);
        ((Mutating) this.asAdmin().getEndStep()).addPropertyMutations(Arrays.copyOfRange(propertyKeyValues, 1, propertyKeyValues.length));
        return (GraphTraversal<S, Edge>) this;
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:26,代码来源:GraphTraversal.java

示例6: vertices

import org.apache.tinkerpop.gremlin.structure.Direction; //导入方法依赖的package包/类
@Override
public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) {
    return TinkerHelper.inComputerMode(this.graph) ?
            direction.equals(Direction.BOTH) ?
                    IteratorUtils.concat(
                            IteratorUtils.map(this.edges(Direction.OUT, edgeLabels), Edge::inVertex),
                            IteratorUtils.map(this.edges(Direction.IN, edgeLabels), Edge::outVertex)) :
                    IteratorUtils.map(this.edges(direction, edgeLabels), edge -> edge.vertices(direction.opposite()).next()) :
            (Iterator) TinkerHelper.getVertices(this, direction, edgeLabels);
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:11,代码来源:TinkerVertex.java

示例7: dropEdges

import org.apache.tinkerpop.gremlin.structure.Direction; //导入方法依赖的package包/类
public void dropEdges(final Direction direction) {
    if ((direction.equals(Direction.OUT) || direction.equals(Direction.BOTH)) && null != this.outEdges) {
        this.outEdges.clear();
        this.outEdges = null;
    }
    if ((direction.equals(Direction.IN) || direction.equals(Direction.BOTH)) && null != this.inEdges) {
        this.inEdges.clear();
        this.inEdges = null;
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:11,代码来源:StarGraph.java

示例8: vertices

import org.apache.tinkerpop.gremlin.structure.Direction; //导入方法依赖的package包/类
@Override
public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) {
    if (direction.equals(Direction.OUT))
        return IteratorUtils.map(this.edges(direction, edgeLabels), Edge::inVertex);
    else if (direction.equals(Direction.IN))
        return IteratorUtils.map(this.edges(direction, edgeLabels), Edge::outVertex);
    else
        return IteratorUtils.concat(this.vertices(Direction.IN, edgeLabels), this.vertices(Direction.OUT, edgeLabels));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:10,代码来源:StarGraph.java

示例9: vertices

import org.apache.tinkerpop.gremlin.structure.Direction; //导入方法依赖的package包/类
@Override
public Iterator<Vertex> vertices(final Direction direction) {
    if (direction.equals(Direction.OUT))
        return IteratorUtils.of(this.outVertex);
    else if (direction.equals(Direction.IN))
        return IteratorUtils.of(this.inVertex);
    else
        return IteratorUtils.of(this.outVertex, this.inVertex);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:10,代码来源:ReferenceEdge.java

示例10: isOptimizable

import org.apache.tinkerpop.gremlin.structure.Direction; //导入方法依赖的package包/类
/**
 * Checks whether a given step is optimizable or not.
 *
 * @param step1 an edge-emitting step
 * @param step2 a vertex-emitting step
 * @return <code>true</code> if step1 is not labeled and emits edges and step2 emits vertices,
 * otherwise <code>false</code>
 */
private static boolean isOptimizable(final Step step1, final Step step2) {
    if (step1 instanceof VertexStep && ((VertexStep) step1).returnsEdge() && step1.getLabels().isEmpty()) {
        final Direction step1Dir = ((VertexStep) step1).getDirection();
        if (step1Dir.equals(Direction.BOTH)) {
            return step2 instanceof EdgeOtherVertexStep;
        }
        return step2 instanceof EdgeVertexStep && ((EdgeVertexStep) step2).getDirection().equals(step1Dir.opposite());
    }
    return false;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:19,代码来源:IncidentToAdjacentStrategy.java

示例11: vertices

import org.apache.tinkerpop.gremlin.structure.Direction; //导入方法依赖的package包/类
@Override
public Iterator<Vertex> vertices(final Direction direction) {
    if (direction.equals(Direction.OUT))
        return IteratorUtils.of(this.outVertex());
    if (direction.equals(Direction.IN))
        return IteratorUtils.of(this.inVertex());
    else
        return IteratorUtils.of(this.outVertex(), this.inVertex());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:10,代码来源:ComputerGraph.java

示例12: mapDirection

import org.apache.tinkerpop.gremlin.structure.Direction; //导入方法依赖的package包/类
public static org.neo4j.tinkerpop.api.Neo4jDirection mapDirection(final Direction direction) {
    if (direction.equals(Direction.OUT))
        return org.neo4j.tinkerpop.api.Neo4jDirection.OUTGOING;
    else if (direction.equals(Direction.IN))
        return org.neo4j.tinkerpop.api.Neo4jDirection.INCOMING;
    else
        return org.neo4j.tinkerpop.api.Neo4jDirection.BOTH;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:Neo4jHelper.java


注:本文中的org.apache.tinkerpop.gremlin.structure.Direction.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。