| /** |
| */ |
| package graph.util; |
| |
| import graph.*; |
| |
| import java.util.Map; |
| |
| import org.eclipse.emf.common.util.Diagnostic; |
| import org.eclipse.emf.common.util.DiagnosticChain; |
| import org.eclipse.emf.common.util.ResourceLocator; |
| |
| import org.eclipse.emf.ecore.EPackage; |
| |
| import org.eclipse.emf.ecore.util.EObjectValidator; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * The <b>Validator</b> for the model. |
| * <!-- end-user-doc --> |
| * @see graph.GraphPackage |
| * @generated |
| */ |
| public class GraphValidator extends EObjectValidator { |
| /** |
| * The cached model package |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public static final GraphValidator INSTANCE = new GraphValidator(); |
| |
| /** |
| * A constant for the {@link org.eclipse.emf.common.util.Diagnostic#getSource() source} of diagnostic {@link org.eclipse.emf.common.util.Diagnostic#getCode() codes} from this package. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see org.eclipse.emf.common.util.Diagnostic#getSource() |
| * @see org.eclipse.emf.common.util.Diagnostic#getCode() |
| * @generated |
| */ |
| public static final String DIAGNOSTIC_SOURCE = "graph"; |
| |
| /** |
| * A constant with a fixed name that can be used as the base value for additional hand written constants. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| private static final int GENERATED_DIAGNOSTIC_CODE_COUNT = 0; |
| |
| /** |
| * A constant with a fixed name that can be used as the base value for additional hand written constants in a derived class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected static final int DIAGNOSTIC_CODE_COUNT = GENERATED_DIAGNOSTIC_CODE_COUNT; |
| |
| /** |
| * Creates an instance of the switch. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public GraphValidator() { |
| super(); |
| } |
| |
| /** |
| * Returns the package of this validator switch. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EPackage getEPackage() { |
| return GraphPackage.eINSTANCE; |
| } |
| |
| /** |
| * Calls <code>validateXXX</code> for the corresponding classifier of the model. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected boolean validate(int classifierID, Object value, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| switch (classifierID) { |
| case GraphPackage.GRAPH: |
| return validateGraph((Graph)value, diagnostics, context); |
| case GraphPackage.NODE: |
| return validateNode((Node)value, diagnostics, context); |
| case GraphPackage.EDGE: |
| return validateEdge((Edge)value, diagnostics, context); |
| case GraphPackage.ATTRIBUTE: |
| return validateAttribute((Attribute)value, diagnostics, context); |
| default: |
| return true; |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validateGraph(Graph graph, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| if (!validate_NoCircularContainment(graph, diagnostics, context)) return false; |
| boolean result = validate_EveryMultiplicityConforms(graph, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryDataValueConforms(graph, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(graph, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(graph, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryProxyResolves(graph, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_UniqueID(graph, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryKeyUnique(graph, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(graph, diagnostics, context); |
| if (result || diagnostics != null) result &= validateGraph_CorrectlyTypedNodes(graph, diagnostics, context); |
| return result; |
| } |
| |
| /** |
| * The cached validation expression for the CorrectlyTypedNodes constraint of '<em>Graph</em>'. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected static final String GRAPH__CORRECTLY_TYPED_NODES__EEXPRESSION = "self.nodes -> forAll(node | self.typegraph.eClassifiers -> includes(node.type))"; |
| |
| /** |
| * Validates the CorrectlyTypedNodes constraint of '<em>Graph</em>'. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validateGraph_CorrectlyTypedNodes(Graph graph, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| return |
| validate |
| (GraphPackage.Literals.GRAPH, |
| graph, |
| diagnostics, |
| context, |
| "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot", |
| "CorrectlyTypedNodes", |
| GRAPH__CORRECTLY_TYPED_NODES__EEXPRESSION, |
| Diagnostic.ERROR, |
| DIAGNOSTIC_SOURCE, |
| 0); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validateNode(Node node, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| if (!validate_NoCircularContainment(node, diagnostics, context)) return false; |
| boolean result = validate_EveryMultiplicityConforms(node, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryDataValueConforms(node, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(node, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(node, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryProxyResolves(node, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_UniqueID(node, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryKeyUnique(node, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(node, diagnostics, context); |
| if (result || diagnostics != null) result &= validateNode_CorrectlyTypedAttributes(node, diagnostics, context); |
| return result; |
| } |
| |
| /** |
| * The cached validation expression for the CorrectlyTypedAttributes constraint of '<em>Node</em>'. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected static final String NODE__CORRECTLY_TYPED_ATTRIBUTES__EEXPRESSION = "self.attributes -> forAll(attr | self.type.eAllAttributes -> includes(attr.type))"; |
| |
| /** |
| * Validates the CorrectlyTypedAttributes constraint of '<em>Node</em>'. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validateNode_CorrectlyTypedAttributes(Node node, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| return |
| validate |
| (GraphPackage.Literals.NODE, |
| node, |
| diagnostics, |
| context, |
| "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot", |
| "CorrectlyTypedAttributes", |
| NODE__CORRECTLY_TYPED_ATTRIBUTES__EEXPRESSION, |
| Diagnostic.ERROR, |
| DIAGNOSTIC_SOURCE, |
| 0); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validateEdge(Edge edge, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| if (!validate_NoCircularContainment(edge, diagnostics, context)) return false; |
| boolean result = validate_EveryMultiplicityConforms(edge, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryDataValueConforms(edge, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(edge, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(edge, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryProxyResolves(edge, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_UniqueID(edge, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryKeyUnique(edge, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(edge, diagnostics, context); |
| if (result || diagnostics != null) result &= validateEdge_CorrectlyTypedEdgesSourceNode(edge, diagnostics, context); |
| if (result || diagnostics != null) result &= validateEdge_CorrectlyTypedEdgesTargetNode(edge, diagnostics, context); |
| return result; |
| } |
| |
| /** |
| * The cached validation expression for the CorrectlyTypedEdgesSourceNode constraint of '<em>Edge</em>'. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected static final String EDGE__CORRECTLY_TYPED_EDGES_SOURCE_NODE__EEXPRESSION = "self.source.type.eAllReferences -> includes(self.type)"; |
| |
| /** |
| * Validates the CorrectlyTypedEdgesSourceNode constraint of '<em>Edge</em>'. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validateEdge_CorrectlyTypedEdgesSourceNode(Edge edge, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| return |
| validate |
| (GraphPackage.Literals.EDGE, |
| edge, |
| diagnostics, |
| context, |
| "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot", |
| "CorrectlyTypedEdgesSourceNode", |
| EDGE__CORRECTLY_TYPED_EDGES_SOURCE_NODE__EEXPRESSION, |
| Diagnostic.ERROR, |
| DIAGNOSTIC_SOURCE, |
| 0); |
| } |
| |
| /** |
| * The cached validation expression for the CorrectlyTypedEdgesTargetNode constraint of '<em>Edge</em>'. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected static final String EDGE__CORRECTLY_TYPED_EDGES_TARGET_NODE__EEXPRESSION = "(self.target.type = self.type.eReferenceType) or (self.target.type.eAllSuperTypes -> includes(self.type.eReferenceType))"; |
| |
| /** |
| * Validates the CorrectlyTypedEdgesTargetNode constraint of '<em>Edge</em>'. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validateEdge_CorrectlyTypedEdgesTargetNode(Edge edge, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| return |
| validate |
| (GraphPackage.Literals.EDGE, |
| edge, |
| diagnostics, |
| context, |
| "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot", |
| "CorrectlyTypedEdgesTargetNode", |
| EDGE__CORRECTLY_TYPED_EDGES_TARGET_NODE__EEXPRESSION, |
| Diagnostic.ERROR, |
| DIAGNOSTIC_SOURCE, |
| 0); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validateAttribute(Attribute attribute, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| return validate_EveryDefaultConstraint(attribute, diagnostics, context); |
| } |
| |
| /** |
| * Returns the resource locator that will be used to fetch messages for this validator's diagnostics. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public ResourceLocator getResourceLocator() { |
| // TODO |
| // Specialize this to return a resource locator for messages specific to this validator. |
| // Ensure that you remove @generated or mark it @generated NOT |
| return super.getResourceLocator(); |
| } |
| |
| } //GraphValidator |