Skip to content

Package: TemplateModelMigratorUtil

TemplateModelMigratorUtil

nameinstructionbranchcomplexitylinemethod
getTemplateModelWorkspaceMigrator()
M: 7 C: 16
70%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 2 C: 7
78%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2018 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.spi.view.migrator;
15:
16: import org.osgi.framework.Bundle;
17: import org.osgi.framework.BundleContext;
18: import org.osgi.framework.FrameworkUtil;
19: import org.osgi.framework.ServiceReference;
20:
21: /**
22: * @author Lucas Koehler
23: * @since 1.17
24: *
25: */
26: public final class TemplateModelMigratorUtil {
27:
28:         private static TemplateModelWorkspaceMigrator templateModelWorkspaceMigrator;
29:
30:         // Utility class should not be instantiated.
31:         private TemplateModelMigratorUtil() {
32:         }
33:
34:         /**
35:          * Returns a {@link TemplateModelWorkspaceMigrator} if any is registered. Otherwise, <code>null</code> is returned.
36:          *
37:          * @return The {@link TemplateModelWorkspaceMigrator}, or <code>null</code> if none is registered.
38:          */
39:         public static TemplateModelWorkspaceMigrator getTemplateModelWorkspaceMigrator() {
40:•                if (templateModelWorkspaceMigrator == null) {
41:                         final Bundle bundle = FrameworkUtil.getBundle(TemplateModelMigratorUtil.class);
42:                         final BundleContext bundleContext = bundle.getBundleContext();
43:                         final ServiceReference<TemplateModelWorkspaceMigrator> serviceReference = bundleContext
44:                                 .getServiceReference(TemplateModelWorkspaceMigrator.class);
45:•                        if (serviceReference == null) {
46:                                 return null;
47:                         }
48:                         templateModelWorkspaceMigrator = bundleContext.getService(serviceReference);
49:                 }
50:                 return templateModelWorkspaceMigrator;
51:         }
52: }