blob: 4c84d865d70850a8c40cd7814c5ef8dcdc4858b9 [file] [log] [blame]
/**
* Copyright (c) 2011-2018 EclipseSource Muenchen GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* EclipseSource Muenchen GmbH - initial API and implementation
*/
package org.eclipse.emf.ecp.edit.internal.model.testData.util;
import java.util.Map;
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 org.eclipse.emf.ecp.edit.internal.model.testData.TestData;
import org.eclipse.emf.ecp.edit.internal.model.testData.TestDataPackage;
/**
* <!-- begin-user-doc -->
* The <b>Validator</b> for the model.
* <!-- end-user-doc -->
*
* @see org.eclipse.emf.ecp.edit.internal.model.testData.TestDataPackage
* @generated
*/
public class TestDataValidator extends EObjectValidator {
/**
* The cached model package
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public static final TestDataValidator INSTANCE = new TestDataValidator();
/**
* 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 = "org.eclipse.emf.ecp.edit.internal.model.testData"; //$NON-NLS-1$
/**
* 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 TestDataValidator() {
super();
}
/**
* Returns the package of this validator switch.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EPackage getEPackage() {
return TestDataPackage.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 TestDataPackage.TEST_DATA:
return validateTestData((TestData) value, diagnostics, context);
case TestDataPackage.STRING_WITH_MAX_LENGTH8:
return validateStringWithMaxLength8((String) value, diagnostics, context);
default:
return true;
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public boolean validateTestData(TestData testData, DiagnosticChain diagnostics, Map<Object, Object> context) {
return validate_EveryDefaultConstraint(testData, diagnostics, context);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public boolean validateStringWithMaxLength8(String stringWithMaxLength8, DiagnosticChain diagnostics,
Map<Object, Object> context) {
final boolean result = validateStringWithMaxLength8_MaxLength(stringWithMaxLength8, diagnostics, context);
return result;
}
/**
* Validates the MaxLength constraint of '<em>String With Max Length8</em>'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public boolean validateStringWithMaxLength8_MaxLength(String stringWithMaxLength8, DiagnosticChain diagnostics,
Map<Object, Object> context) {
final int length = stringWithMaxLength8.length();
final boolean result = length <= 8;
if (!result && diagnostics != null) {
reportMaxLengthViolation(TestDataPackage.Literals.STRING_WITH_MAX_LENGTH8, stringWithMaxLength8, length, 8,
diagnostics, context);
}
return result;
}
/**
* 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();
}
} // TestDataValidator