/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated NOT */ public void putGraphLabel(Label label) { getGraphLabels().put(label.getURI(), label); // Dynamic? if (label instanceof DynamicLabel) { // Yes addDynamicLabel((DynamicLabel) label); } // if DynamicLabel } // putGraphLabel
/** @see org.eclipse.stem.common.impl.IdentifiableImpl#sane() */ @Override public boolean sane() { boolean retValue = super.sane(); // This is the number of labels that each node references int nodeLabelCount = 0; int dynamicLabelCount = 0; // Nodes if (nodes != null) { // Yes for (final Iterator<Node> nodeIter = getNodes().values().iterator(); nodeIter.hasNext() && retValue; ) { final Node node = nodeIter.next(); retValue = retValue && node.sane(); assert retValue; nodeLabelCount += node.getLabels().size(); // How many dynamic labels? for (final Iterator<NodeLabel> labelIter = node.getLabels().iterator(); labelIter.hasNext(); ) { final Label label = labelIter.next(); if (label instanceof DynamicLabel) { dynamicLabelCount++; retValue = false; // The dynamic label should be in the collection of // dynamic labels maintained by the graph for (DynamicLabel dl : getDynamicLabels()) { if (dl == label) { retValue = true; break; } } // for each dynamic label assert retValue; } // if DynamicLabel // The label should be in the collection of node labels retValue = retValue && getNodeLabels().containsKey(label.getURI()); assert retValue; } // for each label of the node } // for each node } // if // Edges? if (edges != null) { // Yes for (final Iterator<Edge> edgeIter = getEdges().values().iterator(); edgeIter.hasNext() && retValue; ) { final Edge edge = edgeIter.next(); retValue = retValue && edge.sane(); assert retValue; // Is the edge's label dynamic? if (edge.getLabel() instanceof DynamicLabel) { // Yes dynamicLabelCount++; } } // for each edge } // if // Node Labels? if (nodeLabels != null) { // Yes // The number of node labels should match the number we counted // above...not true for graph fragments that might have labels for // nodes in other (sub) graph fragments. // retValue = retValue && nodeLabelCount == // getNodeLabels().getSize(); // assert retValue; for (final Iterator<NodeLabel> labelIter = getNodeLabels().values().iterator(); labelIter.hasNext() && retValue; ) { final NodeLabel nodeLabel = labelIter.next(); retValue = retValue && nodeLabel.sane(); assert retValue; } // for each node label } // if if (graphLabels != null) { // Yes for (final Iterator<Label> graphLabelIter = getGraphLabels().values().iterator(); graphLabelIter.hasNext(); ) { final Label graphLabel = graphLabelIter.next(); retValue = retValue && graphLabel.sane(); assert retValue; if (graphLabel instanceof DynamicLabel) { dynamicLabelCount++; } } } // if graphLabels // Dynamic Labels? if (dynamicLabels != null) { // Yes // The number of dynamic labels should equal the count retValue = dynamicLabelCount == getNumDynamicLabels(); assert retValue; for (final Iterator<DynamicLabel> dynamiclIter = getDynamicLabels().iterator(); dynamiclIter.hasNext() && retValue; ) { final DynamicLabel dynamicLabel = dynamiclIter.next(); retValue = retValue && dynamicLabel.sane(); assert retValue; } // for each dynamic label } // if return retValue; } // sane