@Test public void testGetOrCreateNodeByName() { Node node = new Node("x"); assertThat(graph.hasNode("x"), is(false)); Node x = graph.getOrCreateNodeByName("x"); assertEquals(node, x); assertNotSame(node, x); assertThat(graph.hasNode("x"), is(true)); Node y = graph.getOrCreateNodeByName("x"); assertSame(x, y); }
@Override public Node getOrCreateNodeByName(String name) { Node node = nodeMap.get(name); if (node == null) { node = new Node(name); addNode(node); } return node; }
DependencyGraphSimpleImpl implements DependencyGraph { @Override public Node getOrCreateNodeByName(String name) { Node node = nodeMap.get(name); if (node == null) { node = new Node(name); addNode(node); } return node; } }
DependencyGraphSimpleImpl implements DependencyGraph { @Override public Node getOrCreateNodeByName(String name) { Node node = nodeMap.get(name); if (node == null) { node = new Node(name); addNode(node); } return node; } @SuppressWarnings("squid:S3366") // Sonar warns that "this" may be used by another thread before the object is completely created. In this setting // here, there won't be a problem.  DependencyGraphSimpleImpl();  DependencyGraphSimpleImpl(DependencyGraph baseGraph); }
DependencyGraphSimpleImpl implements DependencyGraph { @Override public Node getOrCreateNodeByName(String name) { Node node = nodeMap.get(name); if (node == null) { node = new Node(name); addNode(node); } return node; } @SuppressWarnings("squid:S3366") // Sonar warns that "this" may be used by another thread before the object is completely created. In this setting // here, there won't be a problem.  DependencyGraphSimpleImpl();  DependencyGraphSimpleImpl(DependencyGraph baseGraph); @Override DependencyGraph getBaseGraph(); @Override Node getOrCreateNodeByName(String name); @Override Node getNode(String name); @Override boolean hasNode(String name); @Override Dependency addDependency(Node from, Node to, DependencyType type); @Override Dependency getEdge(Node from, Node to); @Override Set<Dependency> getOutgoingEdges(Node node); @Override Set<Dependency> getOutgoingEdges(Node node, DependencyType dependencyType); @Override Set<Dependency> getIncomingEdges(Node node); @Override Set<Dependency> getIncomingEdges(Node node, DependencyType dependencyType); @Override DependencyGraph filter(final NodeFilter filter); @Override DependencyGraph filter(final EdgeFilter filter); @Override Collection<Node> getAllNodes(); @Override Collection<Dependency> getAllEdges(); AbstractGraph<Node, Dependency> getGraph(); @Override String toString(); }
DependencyGraphSimpleImpl implements DependencyGraph { @Override public Node getOrCreateNodeByName(String name) { Node node = nodeMap.get(name); if (node == null) { node = new Node(name); addNode(node); } return node; } @SuppressWarnings("squid:S3366") // Sonar warns that "this" may be used by another thread before the object is completely created. In this setting // here, there won't be a problem.  DependencyGraphSimpleImpl();  DependencyGraphSimpleImpl(DependencyGraph baseGraph); @Override DependencyGraph getBaseGraph(); @Override Node getOrCreateNodeByName(String name); @Override Node getNode(String name); @Override boolean hasNode(String name); @Override Dependency addDependency(Node from, Node to, DependencyType type); @Override Dependency getEdge(Node from, Node to); @Override Set<Dependency> getOutgoingEdges(Node node); @Override Set<Dependency> getOutgoingEdges(Node node, DependencyType dependencyType); @Override Set<Dependency> getIncomingEdges(Node node); @Override Set<Dependency> getIncomingEdges(Node node, DependencyType dependencyType); @Override DependencyGraph filter(final NodeFilter filter); @Override DependencyGraph filter(final EdgeFilter filter); @Override Collection<Node> getAllNodes(); @Override Collection<Dependency> getAllEdges(); AbstractGraph<Node, Dependency> getGraph(); @Override String toString();  }