Skip to content

Package: EMFFormsSpreadsheetValueConverterHelper

EMFFormsSpreadsheetValueConverterHelper

nameinstructionbranchcomplexitylinemethod
getFeature(EObject, VDomainModelReference, EMFFormsDatabindingEMF, ReportService)
M: 8 C: 17
68%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 2 C: 4
67%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2015 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.spi.spreadsheet.core.converter;
15:
16: import org.eclipse.emf.ecore.EObject;
17: import org.eclipse.emf.ecore.EStructuralFeature;
18: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
19: import org.eclipse.emfforms.spi.common.report.ReportService;
20: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
21: import org.eclipse.emfforms.spi.core.services.databinding.emf.EMFFormsDatabindingEMF;
22: import org.eclipse.emfforms.spi.spreadsheet.core.EMFFormsSpreadsheetReport;
23:
24: /**
25: * Helper for converters.
26: *
27: * @author jfaltermeier
28: *
29: */
30: public final class EMFFormsSpreadsheetValueConverterHelper {
31:
32:         private EMFFormsSpreadsheetValueConverterHelper() {
33:                 // util
34:         }
35:
36:         /**
37:          * Gets the feature from the domain model reference using the databinding service. In case of an error, the error
38:          * will be logged and <code>null</code> will be returned.
39:          *
40:          * @param domain the domain object
41:          * @param domainModelReference the domain model reference
42:          * @param databinding the databinding service
43:          * @param reportService the error report service
44:          * @return the feature or <code>null</code>
45:          */
46:         public static EStructuralFeature getFeature(EObject domain,
47:                 VDomainModelReference domainModelReference, EMFFormsDatabindingEMF databinding, ReportService reportService) {
48:                 try {
49:                         return databinding.getSetting(domainModelReference, domain).getEStructuralFeature();
50:                 } catch (final DatabindingFailedException ex) {
51:                         reportService.report(new EMFFormsSpreadsheetReport(ex, EMFFormsSpreadsheetReport.ERROR));
52:                 } catch (final ClassCastException ex) {
53:                         reportService.report(new EMFFormsSpreadsheetReport(ex, EMFFormsSpreadsheetReport.ERROR));
54:                 }
55:                 return null;
56:         }
57: }