| /** |
| * <copyright> |
| * </copyright> |
| * |
| * $Id: PeopleValidator.java,v 1.1 2010/10/29 11:58:02 ewillink Exp $ |
| */ |
| package people.util; |
| |
| 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; |
| |
| import people.*; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * The <b>Validator</b> for the model. |
| * <!-- end-user-doc --> |
| * @see people.PeoplePackage |
| * @generated |
| */ |
| public class PeopleValidator extends EObjectValidator { |
| /** |
| * The cached model package |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public static final PeopleValidator INSTANCE = new PeopleValidator(); |
| |
| /** |
| * 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 = "people"; |
| |
| /** |
| * 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 PeopleValidator() { |
| super(); |
| } |
| |
| /** |
| * Returns the package of this validator switch. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EPackage getEPackage() { |
| return PeoplePackage.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 PeoplePackage.PERSON: |
| return validatePerson((Person)value, diagnostics, context); |
| case PeoplePackage.UNIVERSE: |
| return validateUniverse((Universe)value, diagnostics, context); |
| case PeoplePackage.GENDER: |
| return validateGender((Gender)value, diagnostics, context); |
| default: |
| return true; |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validatePerson(Person person, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| if (!validate_NoCircularContainment(person, diagnostics, context)) return false; |
| boolean result = validate_EveryMultiplicityConforms(person, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryDataValueConforms(person, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(person, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(person, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryProxyResolves(person, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_UniqueID(person, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryKeyUnique(person, diagnostics, context); |
| if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(person, diagnostics, context); |
| if (result || diagnostics != null) result &= validatePerson_null(person, diagnostics, context); |
| if (result || diagnostics != null) result &= validatePerson_MixedGenderParents(person, diagnostics, context); |
| return result; |
| } |
| |
| /** |
| * Validates the null constraint of '<em>Person</em>'. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validatePerson_null(Person person, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| // TODO implement the constraint |
| // -> specify the condition that violates the constraint |
| // -> verify the diagnostic details, including severity, code, and message |
| // Ensure that you remove @generated or mark it @generated NOT |
| if (false) { |
| if (diagnostics != null) { |
| diagnostics.add |
| (createDiagnostic |
| (Diagnostic.ERROR, |
| DIAGNOSTIC_SOURCE, |
| 0, |
| "_UI_GenericConstraint_diagnostic", |
| new Object[] { "null", getObjectLabel(person, context) }, |
| new Object[] { person }, |
| context)); |
| } |
| return false; |
| } |
| return true; |
| } |
| |
| /** |
| * The cached validation expression for the MixedGenderParents constraint of '<em>Person</em>'. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected static final String PERSON__MIXED_GENDER_PARENTS__EEXPRESSION = "father.gender <> mother.gender"; |
| |
| /** |
| * Validates the MixedGenderParents constraint of '<em>Person</em>'. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validatePerson_MixedGenderParents(Person person, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| return |
| validate |
| (PeoplePackage.Literals.PERSON, |
| person, |
| diagnostics, |
| context, |
| "http://www.eclipse.org/emf/2002/Ecore/OCL", |
| "MixedGenderParents", |
| PERSON__MIXED_GENDER_PARENTS__EEXPRESSION, |
| Diagnostic.ERROR, |
| DIAGNOSTIC_SOURCE, |
| 0); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validateUniverse(Universe universe, DiagnosticChain diagnostics, Map<Object, Object> context) { |
| return validate_EveryDefaultConstraint(universe, diagnostics, context); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validateGender(Gender gender, 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(); |
| } |
| |
| } //PeopleValidator |