Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.tinkerpop.frames.annotations;
 
    @Override
    public Class<AdjacencygetAnnotationType() {
        return Adjacency.class;
    }
    @Override
    public Object processVertex(final Adjacency adjacencyfinal Method methodfinal Object[] argumentsfinal FramedGraph framedGraphfinal Vertex vertex) {
        if (ClassUtilities.isGetMethod(method)) {
            final FramedVertexIterable r = new FramedVertexIterable(framedGraphvertex.getVertices(adjacency.direction(), adjacency.label()), ClassUtilities.getGenericClass(method));
            if (ClassUtilities.returnsIterable(method)) {
                return r;
            } else {
                return r.iterator().hasNext() ? r.iterator().next() : null;
            }
        } else if (ClassUtilities.isAddMethod(method)) {
            if (adjacency.direction().equals(.))
                framedGraph.getBaseGraph().addEdge(nullvertex, (Vertex) ((FramedElement) Proxy.getInvocationHandler(arguments[0])).getElement(), adjacency.label());
            else
                framedGraph.getBaseGraph().addEdge(null, (Vertex) ((FramedElement) Proxy.getInvocationHandler(arguments[0])).getElement(), vertexadjacency.label());
            return null;
        } else if (ClassUtilities.isRemoveMethod(method)) {
            removeEdges(adjacency.direction(), adjacency.label(), vertex, (Vertex) ((FramedElement) Proxy.getInvocationHandler(arguments[0])).getElement(), framedGraph);
            return null;
        } else if (ClassUtilities.isSetMethod(method)) {
            removeEdges(adjacency.direction(), adjacency.label(), vertexnullframedGraph);
            if (ClassUtilities.acceptsIterable(method)) {
                for (Object o : (Iterablearguments[0]) {
                    Vertex v = (Vertex) ((FramedElement) Proxy.getInvocationHandler(o)).getElement();
                    if (adjacency.direction().equals(.)) {
                        framedGraph.getBaseGraph().addEdge(nullvertexvadjacency.label());
                    } else {
                        framedGraph.getBaseGraph().addEdge(nullvvertexadjacency.label());
                    }
                }
                return null;
            } else {
                if (null != arguments[0]) {
                    if (adjacency.direction().equals(.)) {
                        framedGraph.getBaseGraph().addEdge(nullvertex, (Vertex) ((FramedElement) Proxy.getInvocationHandler(arguments[0])).getElement(), adjacency.label());
                    } else {
                        framedGraph.getBaseGraph().addEdge(null, (Vertex) ((FramedElement) Proxy.getInvocationHandler(arguments[0])).getElement(), vertexadjacency.label());
                    }
                }
                return null;
            }
        }
        return null;
    }
    @Override
    public Object processEdge(final Adjacency annotationfinal Method methodfinal Object[] argumentsfinal FramedGraph framedGraphfinal Edge elementfinal Direction direction) {
        throw new UnsupportedOperationException();
    }
    private void removeEdges(final Direction directionfinal String labelfinal Vertex elementfinal Vertex otherVertexfinal FramedGraph framedGraph) {
        final Graph graph = framedGraph.getBaseGraph();
        for (final Edge edge : element.getEdges(directionlabel)) {
            if (null == otherVertex || edge.getVertex(direction.opposite()).equals(otherVertex)) {
                graph.removeEdge(edge);
            }
        }
    }
New to GrepCode? Check out our FAQ X