Skip to content

Package: FeatureDmrToRootEClassConverter

FeatureDmrToRootEClassConverter

nameinstructionbranchcomplexitylinemethod
FeatureDmrToRootEClassConverter()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getRootEClass(VDomainModelReference)
M: 0 C: 33
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
isApplicable(VDomainModelReference)
M: 0 C: 7
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2019 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: * Lucas Koehler - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.core.services.segments.featurepath;
15:
16: import org.eclipse.emf.ecore.EClass;
17: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
18: import org.eclipse.emf.ecp.view.spi.model.VFeaturePathDomainModelReference;
19: import org.eclipse.emfforms.spi.core.services.segments.DmrToRootEClassConverter;
20: import org.osgi.service.component.annotations.Component;
21:
22: /**
23: * {@link DmrToRootEClassConverter} for {@link VFeaturePathDomainModelReference}.
24: *
25: * @author Lucas Koehler
26: *
27: */
28: @Component(name = "FeatureDmrToRootEClassConverter")
29: public class FeatureDmrToRootEClassConverter implements DmrToRootEClassConverter {
30:
31:         @Override
32:         public double isApplicable(VDomainModelReference dmr) {
33:•                if (dmr instanceof VFeaturePathDomainModelReference) {
34:                         return 1d;
35:                 }
36:                 return NOT_APPLICABLE;
37:         }
38:
39:         @Override
40:         public EClass getRootEClass(VDomainModelReference dmr) {
41:                 final VFeaturePathDomainModelReference featureDmr = (VFeaturePathDomainModelReference) dmr;
42:•                if (featureDmr.getDomainModelEFeature() == null) {
43:                         throw new IllegalArgumentException(
44:                                 String.format("The DMR %s has no domain model feature.", featureDmr)); //$NON-NLS-1$
45:                 }
46:•                return featureDmr.getDomainModelEReferencePath().isEmpty()
47:                         ? featureDmr.getDomainModelEFeature().getEContainingClass()
48:                         : featureDmr.getDomainModelEReferencePath().get(0).getEContainingClass();
49:         }
50:
51: }