Skip to content

Package: FeatureSegmentGenerator

FeatureSegmentGenerator

nameinstructionbranchcomplexitylinemethod
FeatureSegmentGenerator()
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%
createFeatureSegment(EStructuralFeature)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
generateSegments(List)
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
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.emf.ecp.view.internal.editor.handler;
15:
16: import java.util.List;
17: import java.util.stream.Collectors;
18:
19: import org.eclipse.emf.ecore.EStructuralFeature;
20: import org.eclipse.emf.ecp.common.spi.asserts.Assert;
21: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReferenceSegment;
22: import org.eclipse.emf.ecp.view.spi.model.VFeatureDomainModelReferenceSegment;
23: import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
24:
25: /**
26: * Default implementation of {@link SegmentGenerator} that generates a path of
27: * {@link VFeatureDomainModelReferenceSegment VFeatureDomainModelReferenceSegments}.
28: *
29: * @author Lucas Koehler
30: *
31: */
32: public class FeatureSegmentGenerator implements SegmentGenerator {
33:
34:         @Override
35:         public List<VDomainModelReferenceSegment> generateSegments(List<EStructuralFeature> structuralFeatures) {
36:                 Assert.create(structuralFeatures).notNull();
37:                 return structuralFeatures.stream()
38:                         .map(this::createFeatureSegment)
39:                         .collect(Collectors.toList());
40:         }
41:
42:         /**
43:          * Creates a {@link VFeatureDomainModelReferenceSegment} for the given {@link EStructuralFeature}.
44:          *
45:          * @param structuralFeature The {@link EStructuralFeature} that defines the path part represented by the created
46:          * segment
47:          * @return The created {@link VFeatureDomainModelReference}
48:          */
49:         protected VFeatureDomainModelReferenceSegment createFeatureSegment(final EStructuralFeature structuralFeature) {
50:                 final VFeatureDomainModelReferenceSegment pathSegment = VViewFactory.eINSTANCE
51:                         .createFeatureDomainModelReferenceSegment();
52:                 pathSegment.setDomainModelFeature(structuralFeature.getName());
53:                 return pathSegment;
54:         }
55: }