/*******************************************************************************
 * Copyright (c) 2018 IRT AESE (IRT Saint Exupéry).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0
 *
 * Contributors:
 *     Arnaud Dieumegard (IRT Saint Exupéry) - initial API and implementation
 *******************************************************************************/
/**
 */
package com.irtsaintexupery.pseim.pseim.util;

import com.irtsaintexupery.pseim.pseim.*;

import com.irtsaintexupery.pseim.seim.util.SeimValidator;

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 com.irtsaintexupery.pseim.pseim.PseimPackage
 * @generated
 */
public class PseimValidator extends EObjectValidator {
	/**
	 * The cached model package
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static final PseimValidator INSTANCE = new PseimValidator();

	/**
	 * 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 = "com.irtsaintexupery.pseim.pseim";

	/**
	 * 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;

	/**
	 * The cached base package validator.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SeimValidator seimValidator;

	/**
	 * Creates an instance of the switch.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PseimValidator() {
		super();
		seimValidator = SeimValidator.INSTANCE;
	}

	/**
	 * Returns the package of this validator switch.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EPackage getEPackage() {
		return PseimPackage.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 PseimPackage.LIBRARY:
			return validateLibrary((Library) value, diagnostics, context);
		case PseimPackage.PATTERN:
			return validatePattern((Pattern) value, diagnostics, context);
		case PseimPackage.CARDINALITY_ELEMENT:
			return validateCardinalityElement((CardinalityElement) value, diagnostics, context);
		case PseimPackage.PATTERN_COMPONENT:
			return validatePatternComponent((PatternComponent) value, diagnostics, context);
		case PseimPackage.PATTERN_PORT:
			return validatePatternPort((PatternPort) value, diagnostics, context);
		case PseimPackage.PATTERN_LINK:
			return validatePatternLink((PatternLink) value, diagnostics, context);
		case PseimPackage.MULTIPLICITY_ELEMENT:
			return validateMultiplicityElement((MultiplicityElement) value, diagnostics, context);
		case PseimPackage.IDENTIFIED_ELEMENT:
			return validateIdentifiedElement((IdentifiedElement) value, diagnostics, context);
		case PseimPackage.PATTERN_TYPE_HS:
			return validatePatternTypeHS((PatternTypeHS) value, diagnostics, context);
		case PseimPackage.PATTERN_TYPE_FAILURE_MODE:
			return validatePatternTypeFailureMode((PatternTypeFailureMode) value, diagnostics, context);
		case PseimPackage.SAFETY_TACTIC:
			return validateSafetyTactic((SafetyTactic) value, diagnostics, context);
		case PseimPackage.LINK_TYPE:
			return validateLinkType((LinkType) value, diagnostics, context);
		case PseimPackage.PATTERN_PORT_DIRECTION:
			return validatePatternPortDirection((PatternPortDirection) value, diagnostics, context);
		default:
			return true;
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateLibrary(Library library, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(library, diagnostics, context))
			return false;
		boolean result = validate_EveryMultiplicityConforms(library, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryDataValueConforms(library, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryReferenceIsContained(library, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryBidirectionalReferenceIsPaired(library, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryProxyResolves(library, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_UniqueID(library, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryKeyUnique(library, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryMapEntryUnique(library, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validateIdentifiedElement_uidNotEmpty(library, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validateNamedElement_nameNotEmpty(library, diagnostics, context);
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validatePattern(Pattern pattern, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(pattern, diagnostics, context))
			return false;
		boolean result = validate_EveryMultiplicityConforms(pattern, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryDataValueConforms(pattern, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryReferenceIsContained(pattern, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryBidirectionalReferenceIsPaired(pattern, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryProxyResolves(pattern, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_UniqueID(pattern, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryKeyUnique(pattern, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryMapEntryUnique(pattern, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validateIdentifiedElement_uidNotEmpty(pattern, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validateNamedElement_nameNotEmpty(pattern, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validatePropertyHolder_uniqueKeys(pattern, diagnostics, context);
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateCardinalityElement(CardinalityElement cardinalityElement, DiagnosticChain diagnostics,
			Map<Object, Object> context) {
		if (!validate_NoCircularContainment(cardinalityElement, diagnostics, context))
			return false;
		boolean result = validate_EveryMultiplicityConforms(cardinalityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryDataValueConforms(cardinalityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryReferenceIsContained(cardinalityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryBidirectionalReferenceIsPaired(cardinalityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryProxyResolves(cardinalityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_UniqueID(cardinalityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryKeyUnique(cardinalityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryMapEntryUnique(cardinalityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validateIdentifiedElement_uidNotEmpty(cardinalityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validateNamedElement_nameNotEmpty(cardinalityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validatePropertyHolder_uniqueKeys(cardinalityElement, diagnostics, context);
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validatePatternComponent(PatternComponent patternComponent, DiagnosticChain diagnostics,
			Map<Object, Object> context) {
		if (!validate_NoCircularContainment(patternComponent, diagnostics, context))
			return false;
		boolean result = validate_EveryMultiplicityConforms(patternComponent, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryDataValueConforms(patternComponent, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryReferenceIsContained(patternComponent, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryBidirectionalReferenceIsPaired(patternComponent, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryProxyResolves(patternComponent, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_UniqueID(patternComponent, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryKeyUnique(patternComponent, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryMapEntryUnique(patternComponent, diagnostics, context);
		if (result || diagnostics != null)
			result &= validateMultiplicityElement_cardinalityAsElementOrMult(patternComponent, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validateIdentifiedElement_uidNotEmpty(patternComponent, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validateNamedElement_nameNotEmpty(patternComponent, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validatePropertyHolder_uniqueKeys(patternComponent, diagnostics, context);
		if (result || diagnostics != null)
			result &= validatePatternComponent_contentIsPatternContent(patternComponent, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the contentIsPatternContent constraint of '<em>Pattern Component</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final String PATTERN_COMPONENT__CONTENT_IS_PATTERN_CONTENT__EEXPRESSION = "content->forAll(c | c.oclIsTypeOf(PatternComponent) or c.oclIsTypeOf(PatternPort) or c.oclIsTypeOf(PatternLink))";

	/**
	 * Validates the contentIsPatternContent constraint of '<em>Pattern Component</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validatePatternComponent_contentIsPatternContent(PatternComponent patternComponent,
			DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate(PseimPackage.Literals.PATTERN_COMPONENT, patternComponent, diagnostics, context,
				"http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot", "contentIsPatternContent",
				PATTERN_COMPONENT__CONTENT_IS_PATTERN_CONTENT__EEXPRESSION, Diagnostic.ERROR, DIAGNOSTIC_SOURCE, 0);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validatePatternPort(PatternPort patternPort, DiagnosticChain diagnostics,
			Map<Object, Object> context) {
		if (!validate_NoCircularContainment(patternPort, diagnostics, context))
			return false;
		boolean result = validate_EveryMultiplicityConforms(patternPort, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryDataValueConforms(patternPort, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryReferenceIsContained(patternPort, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryBidirectionalReferenceIsPaired(patternPort, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryProxyResolves(patternPort, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_UniqueID(patternPort, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryKeyUnique(patternPort, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryMapEntryUnique(patternPort, diagnostics, context);
		if (result || diagnostics != null)
			result &= validateMultiplicityElement_cardinalityAsElementOrMult(patternPort, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validateIdentifiedElement_uidNotEmpty(patternPort, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validateNamedElement_nameNotEmpty(patternPort, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validatePropertyHolder_uniqueKeys(patternPort, diagnostics, context);
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validatePatternLink(PatternLink patternLink, DiagnosticChain diagnostics,
			Map<Object, Object> context) {
		if (!validate_NoCircularContainment(patternLink, diagnostics, context))
			return false;
		boolean result = validate_EveryMultiplicityConforms(patternLink, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryDataValueConforms(patternLink, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryReferenceIsContained(patternLink, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryBidirectionalReferenceIsPaired(patternLink, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryProxyResolves(patternLink, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_UniqueID(patternLink, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryKeyUnique(patternLink, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryMapEntryUnique(patternLink, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validateIdentifiedElement_uidNotEmpty(patternLink, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validateNamedElement_nameNotEmpty(patternLink, diagnostics, context);
		if (result || diagnostics != null)
			result &= seimValidator.validatePropertyHolder_uniqueKeys(patternLink, diagnostics, context);
		if (result || diagnostics != null)
			result &= validatePatternLink_srcIsPatternPort(patternLink, diagnostics, context);
		if (result || diagnostics != null)
			result &= validatePatternLink_dstIsPatternPort(patternLink, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the srcIsPatternPort constraint of '<em>Pattern Link</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final String PATTERN_LINK__SRC_IS_PATTERN_PORT__EEXPRESSION = "src.oclIsTypeOf(PatternLink)";

	/**
	 * Validates the srcIsPatternPort constraint of '<em>Pattern Link</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validatePatternLink_srcIsPatternPort(PatternLink patternLink, DiagnosticChain diagnostics,
			Map<Object, Object> context) {
		return validate(PseimPackage.Literals.PATTERN_LINK, patternLink, diagnostics, context,
				"http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot", "srcIsPatternPort",
				PATTERN_LINK__SRC_IS_PATTERN_PORT__EEXPRESSION, Diagnostic.ERROR, DIAGNOSTIC_SOURCE, 0);
	}

	/**
	 * The cached validation expression for the dstIsPatternPort constraint of '<em>Pattern Link</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final String PATTERN_LINK__DST_IS_PATTERN_PORT__EEXPRESSION = "dst.oclIsTypeOf(PatternLink)";

	/**
	 * Validates the dstIsPatternPort constraint of '<em>Pattern Link</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validatePatternLink_dstIsPatternPort(PatternLink patternLink, DiagnosticChain diagnostics,
			Map<Object, Object> context) {
		return validate(PseimPackage.Literals.PATTERN_LINK, patternLink, diagnostics, context,
				"http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot", "dstIsPatternPort",
				PATTERN_LINK__DST_IS_PATTERN_PORT__EEXPRESSION, Diagnostic.ERROR, DIAGNOSTIC_SOURCE, 0);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateMultiplicityElement(MultiplicityElement multiplicityElement, DiagnosticChain diagnostics,
			Map<Object, Object> context) {
		if (!validate_NoCircularContainment(multiplicityElement, diagnostics, context))
			return false;
		boolean result = validate_EveryMultiplicityConforms(multiplicityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryDataValueConforms(multiplicityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryReferenceIsContained(multiplicityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryBidirectionalReferenceIsPaired(multiplicityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryProxyResolves(multiplicityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_UniqueID(multiplicityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryKeyUnique(multiplicityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= validate_EveryMapEntryUnique(multiplicityElement, diagnostics, context);
		if (result || diagnostics != null)
			result &= validateMultiplicityElement_cardinalityAsElementOrMult(multiplicityElement, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the cardinalityAsElementOrMult constraint of '<em>Multiplicity Element</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final String MULTIPLICITY_ELEMENT__CARDINALITY_AS_ELEMENT_OR_MULT__EEXPRESSION = "(not (cardinalityElement.oclIsUndefined())) implies multiplicityValue = 1";

	/**
	 * Validates the cardinalityAsElementOrMult constraint of '<em>Multiplicity Element</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateMultiplicityElement_cardinalityAsElementOrMult(MultiplicityElement multiplicityElement,
			DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate(PseimPackage.Literals.MULTIPLICITY_ELEMENT, multiplicityElement, diagnostics, context,
				"http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot", "cardinalityAsElementOrMult",
				MULTIPLICITY_ELEMENT__CARDINALITY_AS_ELEMENT_OR_MULT__EEXPRESSION, Diagnostic.ERROR, DIAGNOSTIC_SOURCE,
				0);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateIdentifiedElement(IdentifiedElement identifiedElement, DiagnosticChain diagnostics,
			Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(identifiedElement, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validatePatternTypeHS(PatternTypeHS patternTypeHS, DiagnosticChain diagnostics,
			Map<Object, Object> context) {
		return true;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validatePatternTypeFailureMode(PatternTypeFailureMode patternTypeFailureMode,
			DiagnosticChain diagnostics, Map<Object, Object> context) {
		return true;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateSafetyTactic(SafetyTactic safetyTactic, DiagnosticChain diagnostics,
			Map<Object, Object> context) {
		return true;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateLinkType(LinkType linkType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return true;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validatePatternPortDirection(PatternPortDirection patternPortDirection, DiagnosticChain diagnostics,
			Map<Object, Object> context) {
		return true;
	}

	/**
	 * 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();
	}

} //PseimValidator
