Skip to content

Package: ClassifierValidatorWrapper

ClassifierValidatorWrapper

nameinstructionbranchcomplexitylinemethod
ClassifierValidatorWrapper(EClassifier, Set)
M: 0 C: 16
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
getValidatedEClassifier()
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%
validate(EClass, EObject, DiagnosticChain, Map)
M: 0 C: 25
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
validate(EDataType, Object, DiagnosticChain, Map)
M: 0 C: 25
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 7
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 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: * Johannes Faltermeier - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.internal.diagnostician;
15:
16: import java.util.Iterator;
17: import java.util.LinkedHashSet;
18: import java.util.Map;
19: import java.util.Set;
20:
21: import org.eclipse.emf.common.util.DiagnosticChain;
22: import org.eclipse.emf.ecore.EClass;
23: import org.eclipse.emf.ecore.EClassifier;
24: import org.eclipse.emf.ecore.EDataType;
25: import org.eclipse.emf.ecore.EObject;
26: import org.eclipse.emf.ecp.diagnostician.ECPValidator;
27:
28: /**
29: * Wraps {@link ECPValidator}s registered for the same {@link EClassifier}.
30: *
31: * @author jfaltermeier
32: *
33: */
34: public class ClassifierValidatorWrapper extends ECPValidator {
35:
36:         private final Set<EClassifier> classifier;
37:         private final Set<ECPValidator> validators;
38:
39:         /**
40:          * Constructor.
41:          *
42:          * @param classifier the classifier
43:          * @param validators the wrapped validators.
44:          */
45:         public ClassifierValidatorWrapper(EClassifier classifier, Set<ECPValidator> validators) {
46:                 this.classifier = new LinkedHashSet<EClassifier>();
47:                 this.classifier.add(classifier);
48:                 this.validators = validators;
49:         }
50:
51:         /**
52:          * {@inheritDoc}
53:          *
54:          * @see org.eclipse.emf.ecp.diagnostician.ECPValidator#getValidatedEClassifier()
55:          */
56:         @Override
57:         public Set<EClassifier> getValidatedEClassifier() {
58:                 return classifier;
59:         }
60:
61:         /**
62:          * {@inheritDoc}
63:          *
64:          * @see org.eclipse.emf.ecp.diagnostician.ECPValidator#validate(org.eclipse.emf.ecore.EClass,
65:          * org.eclipse.emf.ecore.EObject, org.eclipse.emf.common.util.DiagnosticChain, java.util.Map)
66:          */
67:         @Override
68:         public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) {
69:                 boolean result = true;
70:                 final Iterator<ECPValidator> iterator = validators.iterator();
71:•                while (iterator.hasNext()) {
72:                         final boolean validationResult = iterator.next().validate(eClass, eObject, diagnostics, context);
73:•                        if (!validationResult) {
74:                                 result = validationResult;
75:                         }
76:                 }
77:                 return result;
78:         }
79:
80:         /**
81:          * {@inheritDoc}
82:          *
83:          * @see org.eclipse.emf.ecp.diagnostician.ECPValidator#validate(org.eclipse.emf.ecore.EDataType, java.lang.Object,
84:          * org.eclipse.emf.common.util.DiagnosticChain, java.util.Map)
85:          */
86:         @Override
87:         public boolean validate(EDataType eDataType, Object value, DiagnosticChain diagnostics,
88:                 Map<Object, Object> context) {
89:                 boolean result = true;
90:                 final Iterator<ECPValidator> iterator = validators.iterator();
91:•                while (iterator.hasNext()) {
92:                         final boolean validationResult = iterator.next().validate(eDataType, value, diagnostics, context);
93:•                        if (!validationResult) {
94:                                 result = validationResult;
95:                         }
96:                 }
97:                 return result;
98:         }
99: }