Skip to content

Package: CustomMigrationHelper

CustomMigrationHelper

nameinstructionbranchcomplexitylinemethod
CustomMigrationHelper()
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getBundleNameForClass(String)
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%
getInstance()
M: 0 C: 8
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
loadExtensionPoint()
M: 0 C: 26
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
registerMigration(IConfigurationElement)
M: 0 C: 15
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-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: * jfaltermeier - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.edapt;
15:
16: import java.util.LinkedHashMap;
17: import java.util.Map;
18:
19: import org.eclipse.core.runtime.IConfigurationElement;
20: import org.eclipse.core.runtime.IExtensionRegistry;
21: import org.eclipse.core.runtime.Platform;
22:
23: /**
24: * Helper class for accessing the bundle which registers a custom migration.
25: *
26: * @author jfaltermeier
27: *
28: */
29: public final class CustomMigrationHelper {
30:
31:         private static final String MIGRATION = "migration"; //$NON-NLS-1$
32:         private static final String POINT_ID = "org.eclipse.emf.ecp.view.edapt.customMigrations"; //$NON-NLS-1$
33:
34:         private static CustomMigrationHelper customMigrationHelper;
35:
36:         private final Map<String, String> classToBundleMap;
37:
38:         private CustomMigrationHelper() {
39:                 classToBundleMap = new LinkedHashMap<String, String>();
40:                 loadExtensionPoint();
41:         }
42:
43:         /**
44:          * Returns the instance.
45:          *
46:          * @return the instance
47:          */
48:         public static CustomMigrationHelper getInstance() {
49:•                if (customMigrationHelper == null) {
50:                         customMigrationHelper = new CustomMigrationHelper();
51:                 }
52:                 return customMigrationHelper;
53:         }
54:
55:         private void loadExtensionPoint() {
56:                 final IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
57:                 final IConfigurationElement[] configurationElements = extensionRegistry
58:                         .getConfigurationElementsFor(POINT_ID);
59:
60:•                for (final IConfigurationElement configurationElement : configurationElements) {
61:                         registerMigration(configurationElement);
62:                 }
63:         }
64:
65:         private void registerMigration(IConfigurationElement configurationElement) {
66:                 final String contributor = configurationElement.getContributor().getName();
67:                 final String clazz = configurationElement.getAttribute(MIGRATION);
68:                 classToBundleMap.put(clazz, contributor);
69:         }
70:
71:         /**
72:          * Returns the name of the bundle which contains the custom migration.
73:          *
74:          * @param clazz the fully qualified class name of the custom migration.
75:          * @return the bundle name
76:          */
77:         public String getBundleNameForClass(String clazz) {
78:                 return classToBundleMap.get(clazz);
79:         }
80: }