Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.tinkerpop.blueprints.impls.neo4j2;
  
 

Author(s):
Marko A. Rodriguez (http://markorodriguez.com)
 
 public class Neo4j2Vertex extends Neo4j2Element implements Vertex {
 
     public Neo4j2Vertex(final Node nodefinal Neo4j2Graph graph) {
         super(graph);
         this. = node;
 
     }
 
     public Iterable<EdgegetEdges(final com.tinkerpop.blueprints.Direction directionfinal String... labels) {
         this..autoStartTransaction(false);
         if (direction.equals(....))
             return new Neo4jVertexEdgeIterable(this., (Nodethis..labels);
         else if (direction.equals(....))
             return new Neo4jVertexEdgeIterable(this., (Nodethis..labels);
         else
             return new MultiIterable(Arrays.asList(new Neo4jVertexEdgeIterable(this., (Nodethis..labels), new Neo4jVertexEdgeIterable(this., (Nodethis..labels)));
     }
 
     public Iterable<VertexgetVertices(final com.tinkerpop.blueprints.Direction directionfinal String... labels) {
         this..autoStartTransaction(false);
         if (direction.equals(....))
             return new Neo4jVertexVertexIterable(this., (Nodethis..labels);
         else if (direction.equals(....))
             return new Neo4jVertexVertexIterable(this., (Nodethis..labels);
         else
             return new MultiIterable(Arrays.asList(new Neo4jVertexVertexIterable(this., (Nodethis..labels), new Neo4jVertexVertexIterable(this., (Nodethis..labels)));
     }
 
     public Edge addEdge(final String labelfinal Vertex vertex) {
         return this..addEdge(nullthisvertexlabel);
     }
 
     public Collection<StringgetLabels() {
         this..autoStartTransaction(false);
         final Collection<Stringlabels = new ArrayList<String>();
         for (Label label : getRawVertex().getLabels()) {
             labels.add(label.name());
         }
         return labels;
     }
 
     public void addLabel(String label) {
         .autoStartTransaction(true);
         getRawVertex().addLabel(DynamicLabel.label(label));
     }
 
     public void removeLabel(String label) {
         .autoStartTransaction(true);
         getRawVertex().removeLabel(DynamicLabel.label(label));
     }
 
     public VertexQuery query() {
         this..autoStartTransaction(false);
         return new DefaultVertexQuery(this);
     }
 
     public boolean equals(final Object object) {
         return object instanceof Neo4j2Vertex && ((Neo4j2Vertexobject).getId().equals(this.getId());
     }
 
     public String toString() {
         return StringFactory.vertexString(this);
     }
 
     public Node getRawVertex() {
         return (Nodethis.;
     }
 
     private class Neo4jVertexVertexIterable<T extends Verteximplements Iterable<Neo4j2Vertex> {
         private final Neo4j2Graph graph;
         private final Node node;
         private final Direction direction;
         private final DynamicRelationshipType[] labels;
 
         public Neo4jVertexVertexIterable(final Neo4j2Graph graphfinal Node nodefinal Direction directionfinal String... labels) {
             this. = graph;
            this. = node;
            this. = direction;
            this. = new DynamicRelationshipType[labels.length];
            for (int i = 0; i < labels.lengthi++) {
                this.[i] = DynamicRelationshipType.withName(labels[i]);
            }
        }
        public Iterator<Neo4j2Vertexiterator() {
            .autoStartTransaction(true);
            final Iterator<Relationshipitty;
            if (. > 0)
                itty = .getRelationships().iterator();
            else
                itty = .getRelationships().iterator();
            return new Iterator<Neo4j2Vertex>() {
                public Neo4j2Vertex next() {
                    .autoStartTransaction(false);
                    return new Neo4j2Vertex(itty.next().getOtherNode(), );
                }
                public boolean hasNext() {
                    .autoStartTransaction(false);
                    return itty.hasNext();
                }
                public void remove() {
                    .autoStartTransaction(true);
                    itty.remove();
                }
            };
        }
    }
    private class Neo4jVertexEdgeIterable<T extends Edgeimplements Iterable<Neo4j2Edge> {
        private final Neo4j2Graph graph;
        private final Node node;
        private final Direction direction;
        private final DynamicRelationshipType[] labels;
        public Neo4jVertexEdgeIterable(final Neo4j2Graph graphfinal Node nodefinal Direction directionfinal String... labels) {
            this. = graph;
            this. = node;
            this. = direction;
            this. = new DynamicRelationshipType[labels.length];
            for (int i = 0; i < labels.lengthi++) {
                this.[i] = DynamicRelationshipType.withName(labels[i]);
            }
        }
        public Iterator<Neo4j2Edgeiterator() {
            .autoStartTransaction(true);
            final Iterator<Relationshipitty;
            if (. > 0)
                itty = .getRelationships().iterator();
            else
                itty = .getRelationships().iterator();
            return new Iterator<Neo4j2Edge>() {
                public Neo4j2Edge next() {
                    .autoStartTransaction(false);
                    return new Neo4j2Edge(itty.next(), );
                }
                public boolean hasNext() {
                    .autoStartTransaction(false);
                    return itty.hasNext();
                }
                public void remove() {
                    .autoStartTransaction(true);
                    itty.remove();
                }
            };
        }
    }
New to GrepCode? Check out our FAQ X