public Iterable<Edge> getEdges(final String key, final Object value) { if (supportEdgeIds && key.equals(ID)) { throw new IllegalArgumentException("index key " + ID + " is reserved by IdGraph"); } else { return new IdEdgeIterable(baseGraph.getEdges(key, value), this); } }
public Iterable<Edge> getEdges() { return new IdEdgeIterable(baseGraph.getEdges(), this); }
/** * Return an iterable to all the edges in the graph. * * @param mappingFunc the function to create a new dedicated edge from another * @param <E> the type of the edge after mapping * * @return an iterable reference to all edges in the graph * * @see #getEdges() */ @Nonnull public <E extends Edge> Iterable<E> getEdges(BiFunction<Edge, G, E> mappingFunc) { return new IdElementIterable<>(baseGraph.getEdges(), e -> mappingFunc.apply(e, me())); }
public Edge getEdge(final Object id) { if (null == id) { throw new IllegalArgumentException("edge identifier cannot be null"); } if (supportEdgeIds) { Iterable<Edge> i = baseGraph.getEdges(ID, id); Iterator<Edge> iter = i.iterator(); if (!iter.hasNext()) { return null; } else { Edge e = iter.next(); if (iter.hasNext()) { LOGGER.warning("multiple edges exist with id '" + id + "'. Arbitarily choosing " + e); } return new IdEdge(e, this); } } else { Edge base = baseGraph.getEdge(id); return null == base ? null : new IdEdge(base, this); } }
/** * Return an iterable to all the edges in the graph that have a particular key/value property. * * @param key the key of the edge * @param value the value of the edge * @param mappingFunc the function to create a new dedicated edge from another * @param <E> the type of the edge after mapping * * @return an iterable of edges with provided key and value * * @see #getEdges(String, Object) */ @Nonnull public <E extends Edge> Iterable<E> getEdges(String key, Object value, BiFunction<Edge, G, E> mappingFunc) { checkIndexableKey(key, Edge.class); return new IdElementIterable<>(baseGraph.getEdges(key, value), e -> mappingFunc.apply(e, me())); }
/** * Return the edge referenced by the provided object identifier. * * @param id the identifier of the edge to retrieved from the graph * @param mappingFunc the function to create a new dedicated edge from another * @param <E> the type of the edge after mapping * * @return an {@link Optional} containing the edge referenced by the provided identifier * * @see #getEdge(Object) */ @Nonnull public <E extends Edge> Optional<E> getEdge(Object id, BiFunction<Edge, G, E> mappingFunc) { checkNotNull(id, "id"); Optional<Edge> edge = supportEdgeIds ? MoreIterables.onlyElement(baseGraph.getEdges(ID, id)) : Optional.ofNullable(baseGraph.getEdge(id)); return edge.map(e -> mappingFunc.apply(e, me())); }