Skip to content

Package: ModelReferenceHelper

ModelReferenceHelper

nameinstructionbranchcomplexitylinemethod
createDomainModelReference(EStructuralFeature)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
createDomainModelReference(EStructuralFeature, Collection)
M: 3 C: 18
86%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 1 C: 6
86%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 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: * Eugen Neufeld - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.spi.model;
15:
16: import java.util.Collection;
17:
18: import org.eclipse.emf.ecore.EReference;
19: import org.eclipse.emf.ecore.EStructuralFeature;
20:
21: /**
22: * Helper class to create {@link VDomainModelReference VDomainModelReferences}.
23: *
24: * @author Eugen Neufeld
25: * @since 1.2
26: *
27: */
28: public final class ModelReferenceHelper {
29:
30:         private ModelReferenceHelper() {
31:         }
32:
33:         /**
34:          * Create a simple {@link VDomainModelReference} based on a {@link EStructuralFeature}.
35:          *
36:          * @param feature the feature to use for the {@link VDomainModelReference}
37:          * @return the created {@link VDomainModelReference}
38:          */
39:         public static VDomainModelReference createDomainModelReference(EStructuralFeature feature) {
40:                 final VFeaturePathDomainModelReference domainModelReference = VViewFactory.eINSTANCE
41:                         .createFeaturePathDomainModelReference();
42:                 domainModelReference.setDomainModelEFeature(feature);
43:                 return domainModelReference;
44:         }
45:
46:         /**
47:          * Create a simple {@link VDomainModelReference} based on a {@link EStructuralFeature}.
48:          *
49:          * @param feature the feature to use for the {@link VDomainModelReference}
50:          * @param eReferences the collection of {@link EReference EReferences} to use for the {@link VDomainModelReference}
51:          * @return the created {@link VDomainModelReference}
52:          */
53:
54:         public static VDomainModelReference createDomainModelReference(EStructuralFeature feature,
55:                 Collection<EReference> eReferences) {
56:•                if (eReferences == null || eReferences.isEmpty()) {
57:                         return createDomainModelReference(feature);
58:                 }
59:                 final VFeaturePathDomainModelReference domainModelReference = VViewFactory.eINSTANCE
60:                         .createFeaturePathDomainModelReference();
61:                 domainModelReference.setDomainModelEFeature(feature);
62:                 domainModelReference.getDomainModelEReferencePath().addAll(eReferences);
63:                 return domainModelReference;
64:         }
65: }