DependencyGraph (DependencyGraph graph, Object lock) { return new DependencyGraph() { @Override public Delta createDelta(Iterable<NodeSource> sourcesToProcess, Iterable<NodeSource> deletedSources) throws IOException { synchronized (lock) { return graph.createDelta(sourcesToProcess, deletedSources); } } @Override public DifferentiateResult differentiate(Delta delta, DifferentiateParameters params) { synchronized (lock) { return graph.differentiate(delta, params); } } @Override public void integrate(@NotNull DifferentiateResult diffResult) { synchronized (lock) { graph.integrate(diffResult); } } @Override public Iterable<BackDependencyIndex> getIndices() { return graph.getIndices(); } @Override public @Nullable BackDependencyIndex getIndex(String name) { return graph.getIndex(name); } @Override public Iterable<NodeSource> getSources(@NotNull ReferenceID id) { return graph.getSources(id); } @Override public Iterable<ReferenceID> getRegisteredNodes() { return graph.getRegisteredNodes(); } @Override public Iterable<NodeSource> getSources() { return graph.getSources(); } @Override public Iterable<Node<?, ?>> getNodes(@NotNull NodeSource source) { return graph.getNodes(source); } @Override public <T extends Node<T, ?>> Iterable<T> getNodes(NodeSource src, Class<T> nodeSelector) { return graph.getNodes(src, nodeSelector); } @Override public @NotNull Iterable<ReferenceID> getDependingNodes(@NotNull ReferenceID id) { return graph.getDependingNodes(id); } @Override public void close() throws IOException { synchronized (lock) { graph.close(); } } }; }