Skip to content

Package: GenModelUtil

GenModelUtil

nameinstructionbranchcomplexitylinemethod
addDescriptionTags(GenModel, String)
M: 44 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2016 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.emfforms.editor.genmodel.util;
15:
16: import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
17: import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
18: import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
19:
20: /**
21: * Util class for manipulating {@link GenModel GenModels}.
22: *
23: * @author Johannes Faltermeier
24: *
25: */
26: public final class GenModelUtil {
27:
28:         // TODO API: package is set to internal. Adjust this when API is in final state.
29:
30:         private GenModelUtil() {
31:                 /* util */
32:         }
33:
34:         /**
35:          * Add the given tag as a property description to all GenFeatures, which do not yet have a description.
36:          *
37:          * @param genModel the {@link GenModel}
38:          * @param tag the tag
39:          */
40:         public static void addDescriptionTags(GenModel genModel, String tag) {
41:                 genModel.reconcile();
42:•                for (final GenPackage genPackage : genModel.getGenPackages()) {
43:•                        for (final GenFeature genFeature : genPackage.getAllGenFeatures()) {
44:                                 final String propertyDescription = genFeature.getPropertyDescription();
45:•                                if (propertyDescription != null && !propertyDescription.isEmpty()
46:•                                        && !tag.equalsIgnoreCase(propertyDescription)) {
47:                                         /*
48:                                          * non-null, non-empty description which is not equal to the tag
49:                                          * -> don't override
50:                                          */
51:                                         continue;
52:                                 }
53:                                 genFeature.setPropertyDescription(tag);
54:                         }
55:                 }
56:         }
57:
58: }