public static Node findNode(NodeCollection nodeCollection, String hierarchicalName) { String[] nameParts = hierarchicalName.split("/"); if (nameParts.length == 1) { String nodeName = nameParts[0]; return nodeName.length() > 0 ? nodeCollection.getNode(nodeName) : null; } GraphElement currentElement = (GraphElement) nodeCollection; int startIndex = 0; if (nameParts[0].length() == 0) { // hierarchical name started with a '/' currentElement = currentElement.getProcessDefinition(); startIndex = 1; } for (int i = startIndex; i < nameParts.length; i++) { String namePart = nameParts[i]; if ("..".equals(namePart)) { // namePart calls for parent, but current element is absent if (currentElement == null) return null; currentElement = currentElement.getParent(); } else { // namePart calls for child, but current element is not a collection if (!(currentElement instanceof NodeCollection)) return null; NodeCollection currentCollection = (NodeCollection) currentElement; currentElement = currentCollection.getNode(namePart); } } // current element could be the process definition or might be absent return currentElement instanceof Node ? (Node) currentElement : null; }
public int hashCode() { GraphElement parent = getParent(); int result = 580399073; if (name != null && parent != null) { result += name.hashCode(); } else if (parent instanceof NodeCollection) { NodeCollection nodeCollection = (NodeCollection) parent; int index = nodeCollection.getNodes().indexOf(this); assert index != -1 : nodeCollection.getNodes(); result += index; } else { return super.hashCode(); } return 345105097 * result + parent.hashCode(); }
nodeCollection.addNode(node);
Node to = parent.findNode(toName); if (to == null) { addWarning("failed to resolve destination '" + toName + "' of transition '"
nodeCollection.addNode(node);
Node to = parent.findNode(toName); if (to == null) { addWarning("failed to resolve destination '" + toName + "' of transition '"
public int hashCode() { GraphElement parent = getParent(); int result = 580399073; if (name != null && parent != null) { result += name.hashCode(); } else if (parent instanceof NodeCollection) { NodeCollection nodeCollection = (NodeCollection) parent; int index = nodeCollection.getNodes().indexOf(this); assert index != -1 : nodeCollection.getNodes(); result += index; } else { return super.hashCode(); } return 345105097 * result + parent.hashCode(); }
public static Node findNode(NodeCollection nodeCollection, String hierarchicalName) { String[] nameParts = hierarchicalName.split("/"); if (nameParts.length == 1) { String nodeName = nameParts[0]; return nodeName.length() > 0 ? nodeCollection.getNode(nodeName) : null; } GraphElement currentElement = (GraphElement) nodeCollection; int startIndex = 0; if (nameParts[0].length() == 0) { // hierarchical name started with a '/' currentElement = currentElement.getProcessDefinition(); startIndex = 1; } for (int i = startIndex; i < nameParts.length; i++) { String namePart = nameParts[i]; if ("..".equals(namePart)) { // namePart calls for parent, but current element is absent if (currentElement == null) return null; currentElement = currentElement.getParent(); } else { // namePart calls for child, but current element is not a collection if (!(currentElement instanceof NodeCollection)) return null; NodeCollection currentCollection = (NodeCollection) currentElement; currentElement = currentCollection.getNode(namePart); } } // current element could be the process definition or might be absent return currentElement instanceof Node ? (Node) currentElement : null; }
public boolean equals(Object o) { if (o == this) return true; if (!getClass().isInstance(o)) return false; GraphElement other = (GraphElement) o; if (id != 0 && id == other.getId()) return true; GraphElement parent = getParent(); GraphElement otherParent = other.getParent(); boolean result; if (name != null && parent != null) { result = name.equals(other.getName()); } else if (parent instanceof NodeCollection && otherParent instanceof NodeCollection) { NodeCollection nodeCollection = (NodeCollection) parent; int index = nodeCollection.getNodes().indexOf(this); assert index != -1 : nodeCollection.getNodes(); NodeCollection otherNodeCollection = (NodeCollection) otherParent; int otherIndex = otherNodeCollection.getNodes().indexOf(other); result = index == otherIndex; } else { return false; } return result && parent.equals(otherParent); }