Skip to content

Package: ECPDiagnostician

ECPDiagnostician

nameinstructionbranchcomplexitylinemethod
ECPDiagnostician()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
canValidate(EObject)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
validate(EObject)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
validate(EObject, Map)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
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.diagnostician;
15:
16: import java.util.Map;
17:
18: import org.eclipse.emf.common.util.Diagnostic;
19: import org.eclipse.emf.ecore.EObject;
20: import org.eclipse.emf.ecore.util.Diagnostician;
21: import org.eclipse.emf.ecp.internal.diagnostician.ECPValidatorRegistry;
22:
23: /**
24: * The {@link ECPDiagnostician} will invoke the registered {@link org.eclipse.emf.ecp.diagnostician.ECPValidator
25: * ECPValidators}.
26: *
27: * @author jfaltermeier
28: *
29: */
30: public final class ECPDiagnostician {
31:
32:         /**
33:          * The instance of the {@link ECPDiagnostician}.
34:          */
35:         public static final ECPDiagnostician INSTANCE = new ECPDiagnostician();
36:
37:         private final Diagnostician diagnostician;
38:
39:         private ECPDiagnostician() {
40:                 diagnostician = new Diagnostician(ECPValidatorRegistry.INSTANCE);
41:         }
42:
43:         /**
44:          * Validates the given {@link EObject}.
45:          *
46:          * @param eObject the object to validate.
47:          * @return the diagnostic
48:          */
49:         public Diagnostic validate(EObject eObject) {
50:                 return diagnostician.validate(eObject);
51:         }
52:
53:         /**
54:          * Validates the given {@link EObject}.
55:          *
56:          * @param eObject the object to validate.
57:          * @param contextEntries context entries that may be needed for the validation
58:          * @return the diagnostic
59:          */
60:         public Diagnostic validate(EObject eObject, Map<?, ?> contextEntries) {
61:                 return diagnostician.validate(eObject, contextEntries);
62:         }
63:
64:         /**
65:          * Whether the diagnostician can validate the given object.
66:          *
67:          * @param eObject the object to check
68:          * @return <code>true</code> if a validator is registered for the object, <code>false</code> otherwise
69:          */
70:         public boolean canValidate(EObject eObject) {
71:                 return ECPValidatorRegistry.INSTANCE.hasValidator(eObject.eClass());
72:         }
73: }