Skip to content

Package: TestDataValidator

TestDataValidator

nameinstructionbranchcomplexitylinemethod
TestDataValidator()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getEPackage()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getResourceLocator()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
validate(int, Object, DiagnosticChain, Map)
M: 9 C: 9
50%
M: 2 C: 1
33%
M: 2 C: 1
33%
M: 2 C: 2
50%
M: 0 C: 1
100%
validateStringWithMaxLength8(String, DiagnosticChain, Map)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
validateStringWithMaxLength8_MaxLength(String, DiagnosticChain, Map)
M: 2 C: 22
92%
M: 3 C: 3
50%
M: 3 C: 1
25%
M: 0 C: 6
100%
M: 0 C: 1
100%
validateTestData(TestData, DiagnosticChain, Map)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /**
2: * Copyright (c) 2011-2018 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * EclipseSource Muenchen GmbH - initial API and implementation
13: */
14: package org.eclipse.emf.ecp.edit.internal.model.testData.util;
15:
16: import java.util.Map;
17:
18: import org.eclipse.emf.common.util.DiagnosticChain;
19: import org.eclipse.emf.common.util.ResourceLocator;
20: import org.eclipse.emf.ecore.EPackage;
21: import org.eclipse.emf.ecore.util.EObjectValidator;
22: import org.eclipse.emf.ecp.edit.internal.model.testData.TestData;
23: import org.eclipse.emf.ecp.edit.internal.model.testData.TestDataPackage;
24:
25: /**
26: * <!-- begin-user-doc -->
27: * The <b>Validator</b> for the model.
28: * <!-- end-user-doc -->
29: *
30: * @see org.eclipse.emf.ecp.edit.internal.model.testData.TestDataPackage
31: * @generated
32: */
33: public class TestDataValidator extends EObjectValidator {
34:         /**
35:          * The cached model package
36:          * <!-- begin-user-doc -->
37:          * <!-- end-user-doc -->
38:          *
39:          * @generated
40:          */
41:         public static final TestDataValidator INSTANCE = new TestDataValidator();
42:
43:         /**
44:          * A constant for the {@link org.eclipse.emf.common.util.Diagnostic#getSource() source} of diagnostic
45:          * {@link org.eclipse.emf.common.util.Diagnostic#getCode() codes} from this package.
46:          * <!-- begin-user-doc -->
47:          * <!-- end-user-doc -->
48:          *
49:          * @see org.eclipse.emf.common.util.Diagnostic#getSource()
50:          * @see org.eclipse.emf.common.util.Diagnostic#getCode()
51:          * @generated
52:          */
53:         public static final String DIAGNOSTIC_SOURCE = "org.eclipse.emf.ecp.edit.internal.model.testData"; //$NON-NLS-1$
54:
55:         /**
56:          * A constant with a fixed name that can be used as the base value for additional hand written constants.
57:          * <!-- begin-user-doc -->
58:          * <!-- end-user-doc -->
59:          *
60:          * @generated
61:          */
62:         private static final int GENERATED_DIAGNOSTIC_CODE_COUNT = 0;
63:
64:         /**
65:          * A constant with a fixed name that can be used as the base value for additional hand written constants in a
66:          * derived class.
67:          * <!-- begin-user-doc -->
68:          * <!-- end-user-doc -->
69:          *
70:          * @generated
71:          */
72:         protected static final int DIAGNOSTIC_CODE_COUNT = GENERATED_DIAGNOSTIC_CODE_COUNT;
73:
74:         /**
75:          * Creates an instance of the switch.
76:          * <!-- begin-user-doc -->
77:          * <!-- end-user-doc -->
78:          *
79:          * @generated
80:          */
81:         public TestDataValidator() {
82:                 super();
83:         }
84:
85:         /**
86:          * Returns the package of this validator switch.
87:          * <!-- begin-user-doc -->
88:          * <!-- end-user-doc -->
89:          *
90:          * @generated
91:          */
92:         @Override
93:         protected EPackage getEPackage() {
94:                 return TestDataPackage.eINSTANCE;
95:         }
96:
97:         /**
98:          * Calls <code>validateXXX</code> for the corresponding classifier of the model.
99:          * <!-- begin-user-doc -->
100:          * <!-- end-user-doc -->
101:          *
102:          * @generated
103:          */
104:         @Override
105:         protected boolean validate(int classifierID, Object value, DiagnosticChain diagnostics,
106:                 Map<Object, Object> context) {
107:•                switch (classifierID) {
108:                 case TestDataPackage.TEST_DATA:
109:                         return validateTestData((TestData) value, diagnostics, context);
110:                 case TestDataPackage.STRING_WITH_MAX_LENGTH8:
111:                         return validateStringWithMaxLength8((String) value, diagnostics, context);
112:                 default:
113:                         return true;
114:                 }
115:         }
116:
117:         /**
118:          * <!-- begin-user-doc -->
119:          * <!-- end-user-doc -->
120:          *
121:          * @generated
122:          */
123:         public boolean validateTestData(TestData testData, DiagnosticChain diagnostics, Map<Object, Object> context) {
124:                 return validate_EveryDefaultConstraint(testData, diagnostics, context);
125:         }
126:
127:         /**
128:          * <!-- begin-user-doc -->
129:          * <!-- end-user-doc -->
130:          *
131:          * @generated
132:          */
133:         public boolean validateStringWithMaxLength8(String stringWithMaxLength8, DiagnosticChain diagnostics,
134:                 Map<Object, Object> context) {
135:                 final boolean result = validateStringWithMaxLength8_MaxLength(stringWithMaxLength8, diagnostics, context);
136:                 return result;
137:         }
138:
139:         /**
140:          * Validates the MaxLength constraint of '<em>String With Max Length8</em>'.
141:          * <!-- begin-user-doc -->
142:          * <!-- end-user-doc -->
143:          *
144:          * @generated
145:          */
146:         public boolean validateStringWithMaxLength8_MaxLength(String stringWithMaxLength8, DiagnosticChain diagnostics,
147:                 Map<Object, Object> context) {
148:                 final int length = stringWithMaxLength8.length();
149:•                final boolean result = length <= 8;
150:•                if (!result && diagnostics != null) {
151:                         reportMaxLengthViolation(TestDataPackage.Literals.STRING_WITH_MAX_LENGTH8, stringWithMaxLength8, length, 8,
152:                                 diagnostics, context);
153:                 }
154:                 return result;
155:         }
156:
157:         /**
158:          * Returns the resource locator that will be used to fetch messages for this validator's diagnostics.
159:          * <!-- begin-user-doc -->
160:          * <!-- end-user-doc -->
161:          *
162:          * @generated
163:          */
164:         @Override
165:         public ResourceLocator getResourceLocator() {
166:                 // TODO
167:                 // Specialize this to return a resource locator for messages specific to this validator.
168:                 // Ensure that you remove @generated or mark it @generated NOT
169:                 return super.getResourceLocator();
170:         }
171:
172: } // TestDataValidator