/** * Add a vertex to the underlying graph and return it as a framed vertex. * * @param id the id of the newly created vertex * @param kind the default annotated interface to frame the vertex as * @param <F> the default type of the annotated interface * @return a proxy object backed by the vertex and interpreted from the perspective of the * annotate interface */ public <F> F addVertex(final Object id, final Class<F> kind) { Vertex vertex = addVertex(id); for (FrameInitializer initializer : config.getFrameInitializers()) { initializer.initElement(kind, this, vertex); } return this.frame(vertex, kind); }
/** * Construct a FramedGraph that will frame the elements of the underlying graph. * * @param baseGraph the graph whose elements to frame * @deprecated Use {@link FramedGraphFactory}. */ public FramedGraph(final T baseGraph) { this.baseGraph = baseGraph; config = new FramedGraphConfiguration(); config.setConfiguredGraph(baseGraph); configViaFactory = false; registerAnnotationHandler(new PropertyAnnotationHandler()); registerAnnotationHandler(new AdjacencyAnnotationHandler()); registerAnnotationHandler(new IncidenceAnnotationHandler()); registerAnnotationHandler(new DomainAnnotationHandler()); registerAnnotationHandler(new RangeAnnotationHandler()); registerAnnotationHandler(new GremlinGroovyAnnotationHandler()); }
/** * Add an edge to the underlying graph and return it as a framed edge. * * @param id the id of the newly created edge * @param outVertex the outgoing vertex * @param inVertex the incoming vertex * @param label the label of the edge * @param direction the direction of the edge * @param kind the default annotated interface to frame the edge as * @param <F> the default type of the annotated interface * @return a proxy object backed by the edge and interpreted from the perspective of the annotate * interface */ public <F> F addEdge( final Object id, final Vertex outVertex, final Vertex inVertex, final String label, final Direction direction, final Class<F> kind) { Edge edge = addEdge(id, outVertex, inVertex, label); for (FrameInitializer initializer : config.getFrameInitializers()) { initializer.initElement(kind, this, edge); } return this.frame(edge, direction, kind); }
/** * A helper method for framing a vertex. Note that all framed vertices implement {@link * VertexFrame} to allow access to the underlying element * * @param vertex the vertex to frame * @param kind the default annotated interface to frame the vertex as * @param <F> the default type of the annotated interface * @return a proxy objects backed by a vertex and interpreted from the perspective of the annotate * interface or null if the vertex parameter was null */ public <F> F frame(final Vertex vertex, final Class<F> kind) { if (vertex == null) { return null; } Collection<Class<?>> resolvedTypes = new HashSet<Class<?>>(); resolvedTypes.add(VertexFrame.class); resolvedTypes.add(kind); for (TypeResolver typeResolver : config.getTypeResolvers()) { resolvedTypes.addAll(Arrays.asList(typeResolver.resolveTypes(vertex, kind))); } return (F) Proxy.newProxyInstance( kind.getClassLoader(), resolvedTypes.toArray(new Class[resolvedTypes.size()]), new FramedElement(this, vertex)); }
public GraphQuery query() { return config.getConfiguredGraph().query(); }
public void shutdown() { config.getConfiguredGraph().shutdown(); }
public Features getFeatures() { Features features = config.getConfiguredGraph().getFeatures().copyFeatures(); features.isWrapper = true; return features; }
/** * @return * @deprecated Use {@link Module}s via {@link FramedGraphFactory}. */ public Collection<AnnotationHandler<? extends Annotation>> getAnnotationHandlers() { checkFactoryConfig(); return config.getAnnotationHandlers().values(); }
/** * @param annotationType the type of annotation handled by the annotation handler * @return a boolean indicating if the framedGraph has registered an annotation handler for the * specified type * @deprecated Use {@link Module}s via {@link FramedGraphFactory}. */ public boolean hasAnnotationHandler(final Class<? extends Annotation> annotationType) { checkFactoryConfig(); return config.getAnnotationHandlers().containsKey(annotationType); }
public Iterable<Vertex> getVertices(final String key, final Object value) { return config.getConfiguredGraph().getVertices(key, value); }
public Iterable<Vertex> getVertices() { return config.getConfiguredGraph().getVertices(); }
public void removeEdge(final Edge edge) { config.getConfiguredGraph().removeEdge(edge); }
public void removeVertex(final Vertex vertex) { config.getConfiguredGraph().removeVertex(vertex); }
public Edge addEdge( final Object id, final Vertex outVertex, final Vertex inVertex, final String label) { return config.getConfiguredGraph().addEdge(id, outVertex, inVertex, label); }
public Edge getEdge(final Object id) { return config.getConfiguredGraph().getEdge(id); }
/** * The method used to register a new annotation handler for every new annotation a new annotation * handler has to be registered in the framed graph * * @param handler the annotation handler * @deprecated Use {@link Module}s via {@link FramedGraphFactory}. */ public void registerAnnotationHandler(final AnnotationHandler<? extends Annotation> handler) { checkFactoryConfig(); config.addAnnotationhandler(handler); }
/** * @param annotationType the type of annotation handled by the annotation handler * @return the annotation handler associated with the specified type * @deprecated Use {@link Module}s via {@link FramedGraphFactory}. */ public AnnotationHandler<?> getAnnotationHandler( final Class<? extends Annotation> annotationType) { checkFactoryConfig(); return config.getAnnotationHandlers().get(annotationType); }
/** * Frame vertices according to a particular kind of annotated interface. * * @param key the key of the vertices to get * @param value the value of the vertices to get * @param kind the default annotated interface to frame the vertices as * @param <F> the default type of the annotated interface * @return an iterable of proxy objects backed by the vertices and interpreted from the * perspective of the annotate interface */ public <F> Iterable<F> getVertices(final String key, final Object value, final Class<F> kind) { return new FramedVertexIterable<F>( this, config.getConfiguredGraph().getVertices(key, value), kind); }
/** * @param annotationType the type of the annotation handler to remove * @deprecated Use {@link Module}s via {@link FramedGraphFactory}. */ public void unregisterAnnotationHandler(final Class<? extends Annotation> annotationType) { checkFactoryConfig(); config.getAnnotationHandlers().remove(annotationType); }
public Iterable<Edge> getEdges() { return config.getConfiguredGraph().getEdges(); }
/** * Register a <code>FrameInitializer</code> that will be called whenever a new vertex or edge is * added to the graph. The initializer may mutate the vertex (or graph) before returning the * framed element to the user. * * @param frameInitializer the frame initializer * @deprecated Use {@link Module}s via {@link FramedGraphFactory}. */ public void registerFrameInitializer(FrameInitializer frameInitializer) { checkFactoryConfig(); config.addFrameInitializer(frameInitializer); }
public Iterable<Edge> getEdges(final String key, final Object value) { return config.getConfiguredGraph().getEdges(key, value); }
/** * Frame edges according to a particular kind of annotated interface. * * @param key the key of the edges to get * @param value the value of the edges to get * @param direction the direction of the edges * @param kind the default annotated interface to frame the edges as * @param <F> the default type of the annotated interface * @return an iterable of proxy objects backed by the edges and interpreted from the perspective * of the annotate interface */ public <F> Iterable<F> getEdges( final String key, final Object value, final Direction direction, final Class<F> kind) { return new FramedEdgeIterable<F>( this, config.getConfiguredGraph().getEdges(key, value), direction, kind); }
public Vertex addVertex(final Object id) { return config.getConfiguredGraph().addVertex(id); }